from bisect import bisect
N=int(input())
X=[int(x) for x in input().split()]
Xrev=list(map(lambda x:-x,X[::-1]))
L=int(input())
inf=float("inf")
X.append(X[-1]+L)
Xrev.append(Xrev[-1]+L)
Table=[[inf]*18 for i in range(N)]
Tablerev=[[inf]*18 for i in range(N)]
r=1
for i in range(N):
  if r<=N:
    while X[r]-X[i]<=L:
      r+=1
      if r>N:
        break
  Table[i][0]=r-1
for k in range(1,18):
  for i in range(N):
    if Table[i][k-1]==N:
      Table[i][k]=N
      continue
    Table[i][k]=Table[Table[i][k-1]][k-1]

r=1
for i in range(N):
  if r<=N:
    while Xrev[r]-Xrev[i]<=L:
      r+=1
      if r>N:
        break
  Tablerev[i][0]=r-1
for k in range(1,18):
  for i in range(N):
    if Tablerev[i][k-1]==N:
      Tablerev[i][k]=N
      continue
    Tablerev[i][k]=Tablerev[Tablerev[i][k-1]][k-1]
Q=int(input())
for q in range(Q):
  a,b=map(int,input().split())
  a-=1
  b-=1
  ans=0
  if a<=b:
    while a<b:
      i=bisect(Table[a],b)-1
      ans+=2**i
      a=Table[a][i]
      
  else:
    a,b=N-1-a,N-1-b
    while a<b:
      i=bisect(Tablerev[a],b)-1
      ans+=2**i
      a=Tablerev[a][i]
  print(ans)