import sequtils,strutils,algorithm

var
    N = stdin.readline.parseInt
    X = stdin.readline.split.map(parseInt)
    L = stdin.readline.parseInt
    Q = stdin.readline.parseInt
    a,b : int
    i,j : int
    cnt : int

for q in 1..Q:
    (a, b) = stdin.readline.split.map(parseInt)
    a -= 1
    b -= 1
    cnt = 0
    if a < b:
        i = a
        while true:
            cnt += 1
            j = X.lowerBound(X[i] + L)
            if j == N:
                break
            if X[j] != X[i] + L:
                j -= 1
            if j >= b:
                break
            i = j
        echo cnt
    else:
        i = a
        while true:
            cnt += 1
            j = X.lowerBound(X[i] - L)
            if j <= b:
                break
            i = j
        echo cnt


