import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto N = readln.chomp.to!int;
    auto X = readln.split.map!(to!int).array;
    auto L = readln.chomp.to!int;

    auto dp = new int[][](N, 30); // 頂点iから2^j回の移動で辿りつける最遠頂点
    int left = 0;
    int right = 0;
    while (right < N) {
        if (X[right] - X[left] <= L) {
            right++;
            continue;
        }
        else {
            dp[left][0] = right-1;
            left++;
        }
    }
    while (left < N) dp[left][0] = N-1, left++;

    foreach (j; 0..29) {
        foreach (i; 0..N) {
            dp[i][j+1] = dp[dp[i][j]][j];
        }
    }

    auto Q = readln.chomp.to!int;
    while (Q--) {
        auto s = readln.split.map!(to!int);
        auto a = s[0]-1;
        auto b = s[1]-1;
        if (b < a) swap(a, b);
        auto ans = 0;
        while (dp[a][0] < b) {
            auto k = 0;
            while (dp[a][k+1] < b) k++;
            ans += 2^^k;
            a = dp[a][k];
        }
        writeln(ans+1);
    }
}
