Skip to content
UPEEC

Binary Search

Easy#searching#binary-search· solved by 0 · time limit 2.0 s

The array is sorted and has distinct values. For each query value print its 0-based index, or -1 if it's not present. Use binary search — O(log⁡n)O(\log n) per query.

Input

nn and the sorted array, then qq, then qq query values (one per line).

Output

One answer per line.

Constraints

1≤n,q≤1051 \le n, q \le 10^5

Sample 1

Input

5
1 3 5 7 9
3
7
4
1

Output

3
-1
0

Sign in or join free to run and submit your solution.