import bisect


def max_reach(s, d, dest):
    if d == 0:
        return s

    k = 0
    while d >= (1 << k):
        k += 1
    k -= 1

    return max_reach(dest[s][k], d - (1 << k), dest)


def main():
    N = int(input())
    x = list(map(int, input().split()))
    L = int(input())
    Q = int(input())

    a = []
    b = []
    for i in range(Q):
        ta, tb = map(int, input().split())
        a.append(min(ta - 1, tb - 1))
        b.append(max(ta - 1, tb - 1))

    k = 0
    while N >= (1 << k):
        k += 1

    dest = [[0] * (k + 1) for _ in range(N)]
    for i in range(N):
        dest[i][0] = bisect.bisect_right(x, x[i] + L) - 1

    for i in reversed(range(N)):
        for j in range(1, k + 1):
            dest[i][j] = dest[dest[i][j - 1]][j - 1]

    for i in range(Q):
        x1 = a[i]
        x2 = b[i]
        lb = 0
        ub = N
        while (ub - lb) > 1:
            mid = (ub + lb) // 2
            if x2 <= max_reach(x1, mid, dest):
                ub = mid
            else:
                lb = mid
        print(ub)


if __name__ == '__main__':
    main()
