Xenny and Complicated Story

0

0 votes
Problem

Lets uncomplicate the story.

Given the N numbers (ai where 0 <= i < N), perform 3 kinds of queries:

  1. Type 0 - Find the sum of frequencies of all numbers between X & Y inclusive.
  2. Type 1 - Delete any one occurance of a number Z in array.
  3. 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 <= 106

0 <= ai <= 105

1 <= Q <= 106

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?