# -*- coding: utf-8 -*-
import sys
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def slv(N, X, L, Q, AB):
    n = [0]
    for x in X:
        t = -1
        for j in range(n[-1], len(X)):
            if X[j] - x <= L:
                t = j
            else:
                break
        n.append(t)
    n.pop(0)

    ans = []
    for a, b in AB:
        if a > b:
            a, b = b, a
        a -= 1
        b -= 1
        t = 1
        while n[a] < b:
            t += 1
            a = n[a]
        ans.append(t)

    return ans


def main():
    N = read_int()
    X = read_int_n()
    L = read_int()
    Q = read_int()
    AB = [read_int_n() for _ in range(Q)]
    print(*slv(N, X, L, Q, AB), sep='\n')


if __name__ == '__main__':
    main()
