from bisect import bisect_left
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(inf)
Xrev.append(inf)
Table=[[inf]*18 for i in range(N)]
Tablerev=[[inf]*18 for i in range(N)]
r=1
for i in range(N):
  while X[r]-X[i]<=L:
    r+=1
  Table[i][0]=r-1
for k in range(1,18):
  for i in range(N):
    Table[i][k]=Table[Table[i][k-1]][k-1]
    
r=1
for i in range(N):
  while Xrev[r]-Xrev[i]<=L:
    r+=1
  Tablerev[i][0]=r-1
for k in range(1,18):
  for i in range(N):
    Tablerev[i][k]=Tablerev[Table[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_left(Table[a],b)
      ans+=2**i
      a=Table[a][i]
  else:
    a,b=N-1-a,N-1-b
    while a<b:
      i=bisect_left(Tablerev[a],b)
      ans+=2**i
      a=Tablerev[a][i]
  print(ans)