#P1269. Jump

Jump

Description

Snuke is standing on an infinitely long road.

The position on this road is represented by a real number.

Snuke can perform NN types of jumps. The jump of type ii is symmetric with respect to the point aia_i. That is, if he performs this jump at point xx, he will jump to $2a_i − x4).

You are given QQ queries. In the ii-th query, you are asked to compute the minimum number of jumps Snuke must perform to go from sis_i to tit_i. If tit_i is unreachable from sis_i by performing a series of jumps, print 1−1 instead.

Input

First line of the input contains one integer N(1N200)N(1 \leq N \leq 200) . Next NN lines contain integers aia_{i} , one per line $ \left(0 \leq a_{1}<\ldots<a_{N} \leq 10^{4}\right) $. Next line contains one integer QQ the number of queries (0Q105)\left(0 \leq Q \leq 10^{5}\right) . Each of the next QQ lines contains one query and consists of two integers sis_{i} and tit_{i} (0si,ti104)\left(0 \leq s_{i}, t_{i} \leq 10^{4}\right) .

Output

For each query, print the answer in a single line.

4
1
2
4
7
10
2 3
5 6
6 0
3 7
10 3
7 6
5 5
2 10
4 10
10 10
-1
-1
2
2
-1
-1
0
3
1
0