N = int(input())
X = [int(x) for x in input().split()]
L = int(input())
Q = int(input())
query = [[int(x) - 1 for x in input().split()] for i in range(Q)]
H = [0 for i in range(N)]
X.append(10 ** 9 + L + 1)
s = 0
t = 1
while t < N:
  while X[t] - X[s] <= L:
    t += 1
  H[s] = t - 1
  s += 1
  while s < N - 1:
    if X[t] - X[s] > L:
      H[s] = t - 1
      s += 1
    else:
      break
for q in query:
  a = min(q)
  b = max(q)
  d = 0
  while a < b:
    a = H[a]
    d += 1
  print(d)