#C4304. Distance Between Campsites

    ID: 47828 Type: Default 1000ms 256MiB

Distance Between Campsites

Distance Between Campsites

You are given n campsites located along a straight line, with known coordinates. The task is to compute the distance between pairs of campsites based on several queries.

For a pair of campsites with coordinates \(x_a\) and \(x_b\), the distance is defined as:

\( d = |x_a - x_b| \)

The indices provided in the queries are 1-indexed. Your program should read the input from stdin and output the distance for each query on a new line to stdout.

inputFormat

The first line contains an integer n representing the number of campsites.

The second line contains n space-separated integers, where the i-th integer represents the coordinate \(x_i\) of the campsite.

The third line contains an integer q representing the number of queries.

Each of the next q lines contains two space-separated integers a and b (1-indexed), representing the pair of campsites for which the distance is to be calculated.

outputFormat

Output exactly q lines. Each line should contain a single integer representing the absolute difference between the coordinates of the queried campsites.

## sample
5
10 15 20 25 30
3
1 3
2 5
1 5
10

15 20

</p>