import numpy as np
from libc.string cimport memset
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

ctypedef long long LL
cdef:
    LL mod = 10**9+7
    LL inf = 10**18

cpdef void main():
    N = int(input())
    X = np.array(input().split(), dtype=np.int64)
    L = int(input())
    Q = int(input())
    A, B = np.array([input().split() for _ in range(Q)], dtype=np.int64).T

    dble = np.full((20, N), N-1, dtype=np.int64)
    j = 0
    for i in range(N):
        while j<N-1 and X[j+1] - X[i] <= L:
            j += 1
        dble[0][i] = j
    for d in range(1, 20):
        for i in range(N):
            dble[d, i] = dble[d-1][dble[d-1][i]]
    
    for i in range(Q):
        a = A[i]-1
        b = B[i]-1
        if a > b:
            a, b = b, a

        ans = 1
        for i in range(20-1, -1, -1):
            if dble[i][a] < b:
                ans += 1<<i
                a = dble[i][a]
        print(ans)

solve()
    