n = int(input())
x = list(map(int, input().split()))
l = int(input())
q = int(input())
a = [0]*q
b = [0]*q
for i in range(q):
  a[i], b[i] = list(map(int, input().split()))

import bisect
def calc_day(new_x):
  cur_idx = 0
  i = 0
  length = len(new_x)
  while cur_idx < length-1:
    cur_idx = bisect.bisect_right(new_x, new_x[cur_idx]+l)-1
    #print(cur_idx)
    i+=1
  return i
  
for i in range(q):
  if a[i] > b[i]:
    left = b[i]-1
    right = a[i]-1
    new_x = x[:]
  else:
    left = a[i]-1
    right = b[i]-1
    new_x = x[::-1]
    
  new_x = x[left:right+1]
  print(calc_day(new_x))