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

V = [0]*N
ib = 0
for i in range(N):
    while X[i]-X[ib] > L:
        V[ib] = i-1
        ib += 1
while ib!=N-1:
    V[ib]=N-1
    ib += 1
S = [0]*N
h=N-1
cnt = 1
for i in range(N-2, -1, -1):
    if h==V[i]:
        S[i] = cnt
    else:
        cnt+=1
        h=i+1
        S[i] = cnt
for i in range(Q):
    a, b = map(int, input().split())
    a, b = sorted([a, b])
    print(min(1, S[a-1]-S[b-1]))
