from bisect import bisect_right

n = int(input())
x = list(map(int, input().split()))
l = int(input())
q = int(input())
query = [list(map(int,input().split())) for i in range(q)]

ruiseki = [0]*n
left = 0
cnt = 0
for i in range(n):
    if left >= n-1:
        break
    right = bisect_right(x, x[left]+l)
    for j in range(left+1, min(right, n)):
        ruiseki[j] = cnt+1
    cnt += 1
    left = right-1

for a, b in query:
    ans = abs(ruiseki[a-1] - ruiseki[b-1])
    if ans == 0:
        ans = 1
    print(ans)