from bisect import bisect_left,bisect
n = int(input())
x = list(map(int,input().split()))
t = (n-1).bit_length()
kprv = [[1000 for i in range(t)] for j in range(n-1)]
for i in range(t):
    for j in range(n):
        if j + 2**i > n-1:
            break
        kprv[j][i] = x[j+2**i] - x[j]

L = int(input())
q = int(input())

for _ in range(q):
    a , b = map(lambda x:int(x)-1,input().split())
    cou = 0
    if a > b:
        a , b = b , a
    now = a
    while now < b:
        cou += 1
        p = L
        while True:
            nex = bisect(kprv[now],p)
            if nex == 0:
                break
            else:
                p -= kprv[now][nex-1]
                now += 2**(nex-1)
    print(cou)