import sys,bisect



input=sys.stdin.readline



N=int(eval(input()))

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

L=int(eval(input()))



doubling=[[-1 for i in range(N)] for j in range(20)]

backdoubling=[[-1 for i in range(N)] for j in range(20)]



for i in range(N):

    npos=x[i]+L

    index=bisect.bisect_right(x,npos)

    doubling[0][i]=index-1



for i in range(1,20):

    for j in range(N):

        doubling[i][j]=doubling[i-1][doubling[i-1][j]]



for i in range(N):

    npos=x[i]-L

    index=bisect.bisect_left(x,npos)

    backdoubling[0][i]=index



for i in range(1,20):

    for j in range(N):

        backdoubling[i][j]=backdoubling[i-1][backdoubling[i-1][j]]



def forward(num,start):

    for i in range(20):

        if num>>i &1==1:

            start=doubling[i][start]

    return start



def back(num,start):

    for i in range(20):

        if num>>i &1==1:

            start=backdoubling[i][start]

    return start





for _ in range(int(eval(input()))):

    a,b=list(map(int,input().split()))

    a-=1;b-=1

    if b>=a:

        s=0

        e=N

        while e-s>1:

            test=(e+s)//2

            if forward(test,a)>=b:

                e=test

            else:

                s=test

        if forward(s,a)>=b:

            print(s)

        else:

            print(e)

    else:

        s=0

        e=N

        while e-s>1:

            test=(e+s)//2

            if b>=back(test,a):

                e=test

            else:

                s=test

        if b>=back(s,a):

            print(s)

        else:

            print(e)
import sys,bisect



input=sys.stdin.readline



N=int(eval(input()))

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

L=int(eval(input()))



doubling=[[-1 for i in range(N)] for j in range(20)]



for i in range(N):

    npos=x[i]+L

    index=bisect.bisect_right(x,npos)

    doubling[0][i]=index-1



for i in range(1,20):

    for j in range(N):

        doubling[i][j]=doubling[i-1][doubling[i-1][j]]



forward=[[-1 for i in range(N)] for j in range(20)]



for i in range(N):

    forward[0][i]=i



for i in range(1,20):

    for j in range(N):

        forward[i][j]=doubling[i-1][forward[i-1][j]]



for _ in range(int(eval(input()))):

    a,b=list(map(int,input().split()))

    a-=1;b-=1

    if a>b:

        a,b=b,a

    res=0

    for i in range(19,-1,-1):

        if b>forward[i][a]:

            a=doubling[i][a]

            res+=2**i

    print(res)
import sys, bisect

input = sys.stdin.readline
N = int(eval(input()))
x = list(map(int, input().split()))
L = int(eval(input()))
doubling = [[-1 for i in range(N)] for j in range(20)]
backdoubling = [[-1 for i in range(N)] for j in range(20)]
for i in range(N):
    npos = x[i] + L
    index = bisect.bisect_right(x, npos)
    doubling[0][i] = index - 1
for i in range(1, 20):
    for j in range(N):
        doubling[i][j] = doubling[i - 1][doubling[i - 1][j]]
for i in range(N):
    npos = x[i] - L
    index = bisect.bisect_left(x, npos)
    backdoubling[0][i] = index
for i in range(1, 20):
    for j in range(N):
        backdoubling[i][j] = backdoubling[i - 1][backdoubling[i - 1][j]]


def forward(num, start):
    for i in range(20):
        if num >> i & 1 == 1:
            start = doubling[i][start]
    return start


def back(num, start):
    for i in range(20):
        if num >> i & 1 == 1:
            start = backdoubling[i][start]
    return start


for _ in range(int(eval(input()))):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    if b >= a:
        s = 0
        e = N
        while e - s > 1:
            test = (e + s) // 2
            if forward(test, a) >= b:
                e = test
            else:
                s = test
        if forward(s, a) >= b:
            print(s)
        else:
            print(e)
    else:
        s = 0
        e = N
        while e - s > 1:
            test = (e + s) // 2
            if b >= back(test, a):
                e = test
            else:
                s = test
        if b >= back(s, a):
            print(s)
        else:
            print(e)

import sys, bisect

input = sys.stdin.readline
N = int(eval(input()))
x = list(map(int, input().split()))
L = int(eval(input()))
doubling = [[-1 for i in range(N)] for j in range(20)]
for i in range(N):
    npos = x[i] + L
    index = bisect.bisect_right(x, npos)
    doubling[0][i] = index - 1
for i in range(1, 20):
    for j in range(N):
        doubling[i][j] = doubling[i - 1][doubling[i - 1][j]]
forward = [[-1 for i in range(N)] for j in range(20)]
for i in range(N):
    forward[0][i] = i
for i in range(1, 20):
    for j in range(N):
        forward[i][j] = doubling[i - 1][forward[i - 1][j]]
for _ in range(int(eval(input()))):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    if a > b:
        a, b = b, a
    res = 0
    for i in range(19, -1, -1):
        if b > forward[i][a]:
            a = doubling[i][a]
            res += 2**i
    print(res)

-backdoubling = [[-1 for i in range(N)] for j in range(20)] +forward = [[-1 for i in range(N)] for j in range(20)] -    npos = x[i] - L -    index = bisect.bisect_left(x, npos) -    backdoubling[0][i] = index +    forward[0][i] = i -        backdoubling[i][j] = backdoubling[i - 1][backdoubling[i - 1][j]] - - -def forward(num, start): -    for i in range(20): -        if num >> i & 1 == 1: -            start = doubling[i][start] -    return start - - -def back(num, start): -    for i in range(20): -        if num >> i & 1 == 1: -            start = backdoubling[i][start] -    return start - - +        forward[i][j] = doubling[i - 1][forward[i - 1][j]] -    if b >= a: -        s = 0 -        e = N -        while e - s > 1: -            test = (e + s) // 2 -            if forward(test, a) >= b: -                e = test -            else: -                s = test -        if forward(s, a) >= b: -            print(s) -        else: -            print(e) -    else: -        s = 0 -        e = N -        while e - s > 1: -            test = (e + s) // 2 -            if b >= back(test, a): -                e = test -            else: -                s = test -        if b >= back(s, a): -            print(s) -        else: -            print(e) +    if a > b: +        a, b = b, a +    res = 0 +    for i in range(19, -1, -1): +        if b > forward[i][a]: +            a = doubling[i][a] +            res += 2**i +    print(res)