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

queries = [tuple(map(lambda s: int(s)-1, input().split(' '))) for _ in range(Q)]


Next = [0]*N
for i in range(N):
  j = i
  bound = X[i] + L
  while j < N and X[j] <= bound:
    j += 1
  Next[i] = j-1

for a,b in queries:
  if a > b:
    a,b = b,a
  cnt = 0
  while a < b:
    a = Next[a]
    cnt += 1
  print(str(cnt))