import sys
input=sys.stdin.readline

def check(a,b,n):
  l=n.bit_length()
  for i in range(l):
    if n&(1<<i):
      a=dbl[i][a]
  return a>=b

n=int(input())
arr=list(map(int,input().split()))
l=int(input())
dbl=[[0]*(n+1)]
pos=0
for i in range(n):
  for j in range(pos,n):
    if arr[j]-arr[i]>l:
      dbl[0][i+1]=j
      pos=j
      break
  else:
    dbl[0][i+1]=n
for _ in range(n.bit_length()-1):
  tmp=[0]*(n+1)
  for i in range(n+1):
    tmp[i]=dbl[-1][dbl[-1][i]]
  dbl.append(tmp)
q=int(input())
for _ in range(q):
  a,b=map(int,input().split())
  if a>b:
    a,b=b,a
  l=0
  r=b-a+1
  while r-l!=1:
    mid=(l+r)//2
    if check(a,b,mid):
      r=mid
    else:
      l=mid
  print(r)