from bisect import bisect_right
from itertools import accumulate
import heapq

N = int(input())
X = list(map(int, input().split()))
L = int(input())

G = [[] for i in range(N)]
for i in range(N):
    G[i].append((bisect_right(X, X[i] + L) - 1, 1))


def dijkstra(x):
    d = [float('inf')] * N
    d[x] = 0
    visited = {x}

    # d, u
    hq = [(0, x)]

    while hq:
        u = heapq.heappop(hq)[1]
        visited.add(u)

        for node, cost in G[u]:
            if (node not in visited) and d[node] > d[u] + cost:
                d[node] = d[u] + cost
                heapq.heappush(hq, (d[u]+cost, node))
    return d


dist = dijkstra(0)
for i in range(1, N):
    if dist[i] == float('inf'):
        dist[i] = dist[i-1] + 1

Q = int(input())
for q in range(Q):
    a, b = map(int, input().split())
    a, b = min(a, b) - 1, max(a, b) - 1
    print(max(1, dist[b] - dist[a]))
