bhavesh-and-complicated-story

Lets uncomplicate the story.

Given the N numbers (ai where 0 ≤ i < N), perform 3 kinds of queries:
Type 0 - Find the sum of frequencies of all numbers between X & Y inclusive.
Type 1 - Delete any one occurance of a number Z in array.
Type 2 - Insert the number Z in array.

Input Format

First line contains a single integer N - denoting the total number of numbers.

Second line contains N space-separated integers.

Third line contains a single integer Q - denoting the number of queries.

Q lines follow.

For every query of type 0, the query is of the form - 0 X Y - where 0 represents the query type and X,Y are the starting and ending numbers respectively.

For every query of type 1, the query is of the form 1 Z - where 1 represents the query type and Z is the number whose one occurance to be deleted.

For every query of type 2, the query is of the form 2 Z - where 2 represents the query type and Z is the number which is to be inserted anywhere in array.

Output format

Print the answer for every query of type 0 on a new line.

Constraints

1 ≤ N ≤ 10^6

0 ≤ ai ≤ 10^5

1 ≤ Q ≤ 10^6

SAMPLE INPUT
3
1 1 1
3
0 1 3
1 1
0 1 3

SAMPLE OUTPUT
3
2

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions: