It's been quite a long journey from the airport to the building of secrets. BMP and MSA have come across a room full of different elevators. You know for a fact that there are exactly elevators, with the -th elevator initially located on floor . They do not have much time, so they have to call the closest elevator to them. The building has an interesting quirk though. More elevators were added over the years, which means the newer ones (the elevators that are numbered higher) are faster. Using this knowledge, you decide that if two elevators are at an equal distance from a certain floor, the newer elevator will show up first.
Right now BMP and MSA are busy working on their plan for getting the formula and escaping, which leaves you to decide on the best elevator to choose for various scenarios. There are exactly scenarios.
In the -th scenario, they are on floor and want to travel to floor . They will call the elevator closest to floor , and use it to go to floor , leaving it there for future queries.
Input Specification
The first line consists of a single integer , the number of elevators.
The following lines each contain a single integer , the initial position of the -th elevator.
The next line consists of a single integer , the number of scenarios.
Next lines contain two space separated integers and , representing the starting and ending floors in the -th scenario.
Output Specification
For each of the scenarios, output an integer representing the number of the elevator that is closest for the particular scenario.
Sample Input
3
1
9
8
3
3 4
4 7
10 1
Sample Output
1
1
2
Comments