from itertools import count
from bisect import bisect

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)]

j = 0
for i in range(N):
  bound = X[i] + L
  try:
    while X[j] <= bound:
      j += 1
  except IndexError:
    X[i:] = [[] for _ in range(N-i)]
    n = i
    break
  X[i] = [j-1]

for d in count(0):
  for i in range(n):
    t = X[i][d]
    if t < n:
      X[i].append(X[t][d])
    else:
      n = i
      break
  if n == 0:
    break

for a,b in queries:
  if a > b:
    a,b = b,a

  p = bisect(X[a], b) - 1
  cnt = 0
  while p >= 0:
    cnt += 2**p
    a = X[a][p]
    p = bisect(X[a], b) - 1

  if a < b:
    cnt += 1

  print(cnt)