Олимпиадный тренинг

Задача 40066. Number of numbers on the range


Задача

Темы:
You are given N integers A1, ..., AN.
For each of Q queries specified in the L R X format, output the number elements among AL, ..., AR whose values ​​are X.< /code>

Input
The first line contains an integer N (1 <= N <= 2·105). 
The second line contains integers Ai (1 <= Ai <= N, 1 <= i <= N). 
The third line contains a single integer (1 <= Q <= 2·105).
Each of the following lines contains three integers L, R, ( 1 <= L <= R <= N, 1 <= X <= N).

Imprint
Print lines, ith line contains the answer to the ith query.
 
Examples
# Input Output
1
5
3 1 4 1 5
4
1 5 1
2 4 3
1 5 2
1 3 3
2
0
0
1