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


def solve(num_a, num_b):
    if num_b < num_a:
        num_a, num_b = num_b, num_a
    
    ans = 0
    from_pos = l_pos[num_a - 1]
    to_pos = l_pos[num_b - 1]
    now_pos = from_pos

    while now_pos + num_L < to_pos:
        for index, pos in enumerate(l_pos):
            if pos > now_pos + num_L:
                now_pos = l_pos[index - 1]
                ans += 1
                break
    
    ans += 1
    return ans

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