The Root of Evil
You are given a multiset consisting of numbers.
There are types of queries you are given next:
1 x
— add the positive integer number to the multiset2 x
— delete one occurrence of from the multiset. When performing this operation, it is guaranteed that there is at least one in the multiset.3 x
— find the number of such pairs of elements and in the multiset that , where is the largest such integer number that . It is guaranteed that currently there is at least one element in the multiset when getting this query. Note that is bigger than .
You need to perform such queries. For every query of the -rd type, you need to output the required number of pairs of numbers.
Input
The first line has an integer () — the number of elements in the initial array.
In the second line there are integer numbers () — the elements of the multiset.
In the third line you are given a number () — the number of queries.
In the last lines, there are queries on a separate line. Every query contains two numbers () and where is a type of query and is a number given in a query. It is guaranteed that there is at least query of type .
Output
For every query of -rd type, you need to output the needed amount of pairs for the given .
Examples
Scoring
( points): , , , in each query ;
( points): , in each query ;
( points): there are no queries of and type;
( points): there are no queries of type;
( points): no additional constraints.