You are given an array $$$a$$$, consisting of $$$n$$$ integers. Your task is to process $$$q$$$ queries of two types:
Note that the queries in this task are encoded; each subsequent query can only be decoded after calculating the answer to the preceding query of the second type.
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$).
The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le n$$$).
The third line contains a single integer $$$q$$$ ($$$1 \le q \le 3 \cdot 10^5$$$) — the number of queries.
The next $$$q$$$ lines describe the queries in one of the following formats:
The queries are encoded as follows: let $$$\mathit{last}$$$ be the answer to the latest processed query of the second type (initially, $$$\mathit{last} = 0$$$).
Don't forget to update the value of $$$\mathit{last}$$$ after answering each query of the second type.
Additional constraint on the input: there is at least one query of the second type.
For each query of the second type, print the answer — the number of pairs of indices $$$(i, j)$$$ such that $$$l \le i < j \le r$$$ and $$$a_i \ne a_j$$$.
31 2 352 0 21 0 22 0 21 2 02 1 0
3 2 0
71 3 4 4 7 1 332 1 62 1 02 5 6
13 18 0
In the first example, the actual queries (after decoding) are:
Name |
---|