import sys,bisect

input=sys.stdin.readline

N=int(input())
x=list(map(int,input().split()))
L=int(input())

doubling=[[-1 for i in range(N)] for j in range(20)]
backdoubling=[[-1 for i in range(N)] for j in range(20)]

for i in range(N):
    npos=x[i]+L
    index=bisect.bisect_right(x,npos)
    doubling[0][i]=index-1

for i in range(1,20):
    for j in range(N):
        doubling[i][j]=doubling[i-1][doubling[i-1][j]]

for i in range(N):
    npos=x[i]-L
    index=bisect.bisect_left(x,npos)
    backdoubling[0][i]=index

for i in range(1,20):
    for j in range(N):
        backdoubling[i][j]=backdoubling[i-1][backdoubling[i-1][j]]


for _ in range(int(input())):
    a,b=map(int,input().split())
    a-=1;b-=1
    res=0
    if b>=a:
        for j in range(19,-1,-1):
            if b>=doubling[j][a]:
                a=doubling[j][a]
                res+=2**j
        if a!=b:
            res+=1
        print(res)
    else:
        for j in range(19,-1,-1):
            if backdoubling[j][a]>=b:
                a=backdoubling[j][a]
                res+=2**j
        if a!=b:
            res+=1
        print(res)
