CPython lite logoProblemsContests

48. Binary Search #3

 An array of size n consisting of sorted elements is given.

You are given m queries. For each query, you need to find how many times the number x appears in the array.


Input

The first line contains a natural number, n(1n105).

The second line consists of n numbers separated by spaces, ai(1ai109).

The third line contains a natural number, m(1m105).

The next m lines contain numbers separated by spaces, xi(1xi109).

Output

 Output the answer for each query in m lines.


Sample input 1

10
1 1 2 3 3 3 5 7 8 9
7
1
2
3
4
5
10
1

Sample output 1

2
1
3
0
1
0
2

Login to be able to submit.

MediumAlgorithmsData structuresLoops
103 / 23
Solved / unsolved count
1.5 s / 512 MB
Limits