Given a sequence $A_1, A_2, \ldots, A_N$ of length $N$, write a program that performs the following query:
i j: Output the number of distinct integers in $A_i, A_{i+1}, \ldots, A_j$.
Input
The first line contains the length $N$ of the sequence ($1 \le N \le 100{,}000$).
The second line contains $A_1, A_2, \ldots, A_N$ ($1 \le A_i \le 1{,}000{,}000$).
The third line contains the number $M$ of queries ($1 \le M \le 100{,}000$).
The fourth line through the $M$-th line each contain a query $i, j$ ($1 \le i \le j \le N$).
Output
For each query, output the answer on a separate line.
Examples
Input 1
5 1 1 2 1 3 3 1 5 2 4 3 5
Output 1
3 2 3