import bisect
import math
n = int(input())
x = list(map(int, input().split()))
l = int(input())

max_pow = math.ceil(math.log2(x[-1]//l))+1
next_hotel = [[i for j in range(max_pow+1)] for i in range(n)]

head = 1
tail = 0
while head < n:
    if x[tail]+l < x[head]:
        next_hotel[tail][1] = head-1
        tail += 1
    else:
        head += 1
else:
    for i in range(tail, n):
        next_hotel[i][1] = n-1

for i in range(1, max_pow):
    b = 2**i
    for j in range(n-1):
        next_hotel[j][i+1] = next_hotel[next_hotel[j][i]][i]

q = int(input())
for _ in range(q):
    a, b = map(int, input().split())
    a -= 1
    b -= 1

    if a > b:
        a, b = b, a
    total = 0
    while a < b:
        t = bisect.bisect_left(next_hotel[a], b)
        if t == 0:
            break
        else:
            total += 2**(t-1)
            a = next_hotel[a][t]
    print(total)
