import bisect

def wantp(p,day,db):

    for i in range(len(db)):
        i = len(db)-1-i

        if day & (2 ** i) > 0:
            p = db[i][p]

    return p

N = int(input())

x = list(map(int,input().split()))

L = int(input())

able = []

for i in range(N):

    able.append(bisect.bisect_right(x,x[i] + L) - 1)

#print (able)

db = [able]

while min(db[-1]) != N-1:

    new = []

    for i in range(N):

        new.append(db[-1][db[-1][i]])

    db.append(new)

db1 = db.copy()

for i in range(N):
    x[i] = x[-1] - x[i]
x.reverse()
#print (x)

able = []
for i in range(N):
    able.append(bisect.bisect_right(x,x[i] + L) - 1)
db = [able]
while min(db[-1]) != N-1:
    new = []
    for i in range(N):
        new.append(db[-1][db[-1][i]])
    db.append(new)
db2 = db
#print (db2)


Q = int(input())

for loop in range(Q):

    a,b = map(int,input().split())
    a -= 1
    b -= 1

    if a < b:

        l = 0
        r = N+1

        while r-l != 1:

            m = (l+r) // 2

            np = wantp(a,m,db1)
            #print (a,m,np)

            if np < b:
                l = m
            else:
                r = m

        print (r)

    else:
        a = N-1-a
        b = N-1-b

        l = 0
        r = N+1

        while r-l != 1:

            m = (l+r) // 2

            np = wantp(a,m,db2)
            #print (a,m,np)

            if np < b:
                l = m
            else:
                r = m

        print (r)



    
