# coding: utf-8
num_N = int(input())
l_pos = list(map(int, input().split()))
num_L = int(input())
num_Q = int(input())
l_que = [list(map(int, input().split())) for __ in range(num_Q)]

# dp[k][i] = i番目のホテルからk ** 2日以内に到達可能な最右のホテル番号
dp = [[0] * (num_N + 1) for __ in range(num_N + 1)]
for i in range(1, num_N + 1):
    max_ind = 0
    for ind, pos in enumerate(l_pos):
        if l_pos[i - 1] + num_L >= pos:
            max_ind = max(max_ind, ind)

    dp[0][i] = max_ind + 1

k = 0
while True:
    for i in range(1, num_N + 1):
        dp[k + 1][i] = dp[k][dp[k][i]]
    if dp[k + 1][1] == dp[k + 1][num_N]:
        break
    k += 1


def solve(num_a, num_b):
    if num_a > num_b:
        num_a, num_b = num_b, num_a

    num_k = 0
    while True:
        if dp[num_k][num_a] >= num_b:
            break
        
        num_k += 1
    
    return int(2 ** num_k)

for que in l_que:
    print(solve(que[0], que[1]))