#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 types of jumps. The jump of type is symmetric with respect to the point . That is, if he performs this jump at point , he will jump to $2a_i − x4).
You are given queries. In the -th query, you are asked to compute the minimum number of jumps Snuke must perform to go from to . If is unreachable from by performing a series of jumps, print instead.
Input
First line of the input contains one integer . Next lines contain integers , one per line $ \left(0 \leq a_{1}<\ldots<a_{N} \leq 10^{4}\right) $. Next line contains one integer the number of queries . Each of the next lines contains one query and consists of two integers and .
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