import sys
sys.setrecursionlimit(10 ** 6)  # 変更
from bisect import bisect_left,bisect

n = int(input())
x = list(map(int,input().split()))
L = int(input())
t = n.bit_length()
prv = [n-1] * n
for i in range(n):
    prv[i] = bisect(x,x[i]+L) - 1
kprv = [prv]
S = prv
for i in range(t-1):
    kar = [n-1] * n
    for j in range(n):
        kar[j] = S[S[j]]
    kprv.append(kar)
    S = kar

dub = []
for i in range(n):
    kar = []
    for j in range(len(kprv)):
        kar.append(kprv[j][i])
    dub.append(kar)

q = int(input())
for _ in range(q):
    a , b = map(lambda x:int(x)-1,input().split())
    if a > b:
        a , b = b , a
    now = a
    ans = 0
    while True:
        p = bisect_left(dub[now],b)
        if dub[now][p] == b:
            ans += pow(2,p)
            print(ans)
            break
        else:
            ans += pow(2,p-1)
            now = dub[now][p-1]
            