#P1918. 保龄球

保龄球

Description

DL is tired of fortune-telling, so he often goes to the gym to bowl for fun. Since he has been bowling for decades, technique is not a problem, and he wants to try something new.

DL’s eyesight is really good. He can actually count the number of pins at each spot about ten meters ahead of him. He suddenly realizes this is a chance to show off—after seeing the exact number of pins at each position, he throws from a certain position so that he can knock down a certain number of pins.

  1. ○ ○ ○
  2. ○ ○ ○ ○
  3. ○ ○

As shown above, each “○” represents one pin. If DL wants to knock down 33 pins, he throws from position 11; if he wants to knock down 44 pins, he throws from position 22.

Now he wants to knock down mm pins. He tells you the number of pins at each position. Please give him a throwing position.

Input Format

The first line contains a positive integer nn, the number of positions.

The second line contains nn positive integers aia_i, where aia_i is the number of pins at position ii. It is guaranteed that the numbers of pins at all positions are distinct.

The third line contains a positive integer QQ, the number of DL’s throws.

From the fourth line to the end of file, each line contains a positive integer mm, the number of pins DL wants to knock down.

Output Format

Output QQ lines. Each line contains one integer: the position of DL’s ii-th throw. If there is no solution, output 00.

5
1 2 4 3 5
2
4
7

3
0

Hint

Constraints

For 50%50\% of the testdata, 1n,Q1000,1ai,m1051 \leq n, Q \leq 1000, 1 \leq a_i, m \leq 10^5.

For 100%100\% of the testdata, 1n,Q100000,1ai,m1091 \leq n,Q \leq 100000, 1 \leq a_i, m \leq 10^9.

Translated by ChatGPT 5