import bisect


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))

    bin_ma = 1
    ma = 1
    while bin_ma < N:
        bin_ma *= 2
        ma += 1

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

    for i in reversed(range(N)):
        for j in range(1, ma):
            dist[i][j] = dist[dist[i][j - 1]][j - 1]

    def move(x1, x2):
        lb = -1
        ub = ma - 1
        while (ub - lb) > 1:
            mid = (ub + lb) // 2
            idx = dist[x1][mid]
            if idx < x2:
                lb = mid
            else:
                ub = mid

        if dist[x1][ub] == x2:
            return x2, 2 ** ub
        else:
            return ub - 1, 2 ** (ub - 1)

    for q in range(Q):
        x1 = a[q]
        x2 = b[q]
        ans = 0
        while True:
            x1, day = move(x1, x2)
            ans += day
            if x1 == x2:
                print(ans)
                break


if __name__ == '__main__':
    main()
