import bisect
n=int(input())
x=[int(s)-1 for s in input().split()]
l=int(input())
q=int(input())
p=[[0]*17 for _ in range(n)]
for i in range(n):
    p[i][0]=bisect.bisect_right(x,x[i]+l)-1
for i in range(1,17):
    for j in range(n):
        p[j][i]=p[p[j][i-1]][i-1]
for _ in range(q):
    a,b=sorted(int(s)-1 for s in input().split())
    r=0
    for i in reversed(range(17)):
        if p[a][i]<b:
            a=p[a][i]
            r+=1<<i
    print(r+1)