import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

import bisect



n = int(readline())

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

l = int(readline())

q = int(readline())

ab = list(map(int,read().split()))



dbl_l = [[] for _ in range(n)]

dbl_r = [[] for _ in range(n)]

for dbl,xx in zip([dbl_l,dbl_r],[x,x[::-1]]):

    j = 0

    for i in range(n):

        while(j < n-1):

            if(abs(xx[j+1] - xx[i]) > l):

                break

            j += 1

        dbl[i].append(j)



    for i in range(30):

        if(dbl[0][-1] == n-1):

            break

        for j in range(n):

            dbl[j].append(dbl[ dbl[j][i] ][i])



def calc(a,b,dbl):

    if(dbl[a][0] >= b):

        return 1

    ind = bisect.bisect_left(dbl[a],b) - 1

    return 2**ind + calc(dbl[a][ind],b,dbl)



ans = []

it = iter(ab)

for a,b in zip(it,it):

    a -= 1

    b -= 1

    if(a<b):

        ans.append(calc(a,b,dbl_l))

    else:

        a,b = n-1-a,n-1-b

        ans.append(calc(a,b,dbl_r))



print(('\n'.join(map(str,ans))))
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

import bisect



n = int(readline())

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

l = int(readline())

q = int(readline())

ab = list(map(int,read().split()))



dbl = [[] for _ in range(n)]

j = 0

for i in range(n):

    while(j < n-1):

        if(abs(x[j+1] - x[i]) > l):

            break

        j += 1

    dbl[i].append(j)



for i in range(30):

    if(dbl[0][-1] == n-1):

        break

    for j in range(n):

        dbl[j].append(dbl[ dbl[j][i] ][i])



def calc(a,b):

    if(dbl[a][0] >= b):

        return 1

    ind = bisect.bisect_left(dbl[a],b) - 1

    return 2**ind + calc(dbl[a][ind],b)



ans = []

it = iter(ab)

for a,b in zip(it,it):

    a -= 1

    b -= 1

    a,b = min(a,b),max(a,b)

    ans.append(calc(a,b))



print(('\n'.join(map(str,ans))))
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import bisect

n = int(readline())
x = list(map(int, readline().split()))
l = int(readline())
q = int(readline())
ab = list(map(int, read().split()))
dbl_l = [[] for _ in range(n)]
dbl_r = [[] for _ in range(n)]
for dbl, xx in zip([dbl_l, dbl_r], [x, x[::-1]]):
    j = 0
    for i in range(n):
        while j < n - 1:
            if abs(xx[j + 1] - xx[i]) > l:
                break
            j += 1
        dbl[i].append(j)
    for i in range(30):
        if dbl[0][-1] == n - 1:
            break
        for j in range(n):
            dbl[j].append(dbl[dbl[j][i]][i])


def calc(a, b, dbl):
    if dbl[a][0] >= b:
        return 1
    ind = bisect.bisect_left(dbl[a], b) - 1
    return 2**ind + calc(dbl[a][ind], b, dbl)


ans = []
it = iter(ab)
for a, b in zip(it, it):
    a -= 1
    b -= 1
    if a < b:
        ans.append(calc(a, b, dbl_l))
    else:
        a, b = n - 1 - a, n - 1 - b
        ans.append(calc(a, b, dbl_r))
print(("\n".join(map(str, ans))))

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import bisect

n = int(readline())
x = list(map(int, readline().split()))
l = int(readline())
q = int(readline())
ab = list(map(int, read().split()))
dbl = [[] for _ in range(n)]
j = 0
for i in range(n):
    while j < n - 1:
        if abs(x[j + 1] - x[i]) > l:
            break
        j += 1
    dbl[i].append(j)
for i in range(30):
    if dbl[0][-1] == n - 1:
        break
    for j in range(n):
        dbl[j].append(dbl[dbl[j][i]][i])


def calc(a, b):
    if dbl[a][0] >= b:
        return 1
    ind = bisect.bisect_left(dbl[a], b) - 1
    return 2**ind + calc(dbl[a][ind], b)


ans = []
it = iter(ab)
for a, b in zip(it, it):
    a -= 1
    b -= 1
    a, b = min(a, b), max(a, b)
    ans.append(calc(a, b))
print(("\n".join(map(str, ans))))

-dbl_l = [[] for _ in range(n)] -dbl_r = [[] for _ in range(n)] -for dbl, xx in zip([dbl_l, dbl_r], [x, x[::-1]]): -    j = 0 -    for i in range(n): -        while j < n - 1: -            if abs(xx[j + 1] - xx[i]) > l: -                break -            j += 1 -        dbl[i].append(j) -    for i in range(30): -        if dbl[0][-1] == n - 1: +dbl = [[] for _ in range(n)] +j = 0 +for i in range(n): +    while j < n - 1: +        if abs(x[j + 1] - x[i]) > l: -        for j in range(n): -            dbl[j].append(dbl[dbl[j][i]][i]) +        j += 1 +    dbl[i].append(j) +for i in range(30): +    if dbl[0][-1] == n - 1: +        break +    for j in range(n): +        dbl[j].append(dbl[dbl[j][i]][i]) -def calc(a, b, dbl): +def calc(a, b): -    return 2**ind + calc(dbl[a][ind], b, dbl) +    return 2**ind + calc(dbl[a][ind], b) -    if a < b: -        ans.append(calc(a, b, dbl_l)) -    else: -        a, b = n - 1 - a, n - 1 - b -        ans.append(calc(a, b, dbl_r)) +    a, b = min(a, b), max(a, b) +    ans.append(calc(a, b))