from bisect import bisect_right
N=int(input())
x=[0]+list(map(int,input().split()))
L=int(input())
Q=int(input())
for _ in range(Q):
    a,b=sorted(map(int,input().split()))
    i=0
    while a<b:
        a=bisect_right(x,x[a]+L,a)-1
        i+=1
    print(i)