from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
xx = inpl()
L = int(input())
dd = []
for i,x in enumerate(xx):
    ind = bisect.bisect_right(xx,x+L)
    dd.append(ind-1)

Q = int(input())
for i in range(Q):
    a,b = inpl()
    a,b = min(a,b)-1,max(a,b)-1
    tmp = 0
    while a < b:
        a = dd[a]
        tmp += 1
    print(tmp)
