#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <unordered_set>
#include <unordered_map>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define debug( fmt, ... ) \
        fprintf( stderr, \
                  fmt "\n", \
                  ##__VA_ARGS__ \
        )

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1 << 30;
const double EPS = 1e-10;

double zero(double d) {
    return d < EPS ? 0.0 : d;
}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int MOD = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}

struct prepare {
	prepare() {
	    cout.setf(ios::fixed, ios::floatfield);
	    cout.precision(8);
	    ios_base::sync_with_stdio(false);
	}
} _prepare;

int main() {
    int N;
    cin >> N;

    // 右から左に行く場合は、-にして逆転させる
    vll x(N), mx(N);
    rep(i, N) {
        cin >> x[i];
        mx[N-i-1] = -x[i];
    }

    int L, Q;
    cin >> L >> Q;

    // 各iから2^j回の移動でたどり着ける点
    int logN = (int)log2(N) + 3;
    vvi dpx(N, vi(logN, -1)), dpmx(N, vi(logN, -1));
    // 初回は普通に計算
    rep(i, N) {
        {
            auto it = lower_bound(all(x), x[i] + L);
            if (*it - x[i] > L)
                --it;
            dpx[i][0] = min(N-1, (int)distance(begin(x), it));
        }
        {
            auto it = lower_bound(all(mx), mx[i] + L);
            if (*it - mx[i] > L)
                --it;
            dpmx[i][0] = min(N-1, (int)distance(begin(mx), it));
        }
    }
    // 2回目以降は、前回の移動を利用
    REP(j, 1, logN) {
        rep(i, N) {
            // cerr << dpx[dpx[i][j-1]][j-1] << endl;
            dpx[i][j] = dpx[dpx[i][j-1]][j-1];
            dpmx[i][j] = dpmx[dpmx[i][j-1]][j-1];
        }
    }

    while(Q--) {
        int a, b;
        cin >> a >> b;
        --a, --b;

        auto dp = begin(dpx);

        if(a > b) {
            a = N - a - 1;
            b = N - b - 1;
            dp = begin(dpmx);
        }

        int lb = 0;
        int ub = N;

        while(ub - lb > 1) {
            int med = (lb+ub) / 2;

            int pos = a;
            for(int i=31; i>=0; i--) {
                if( ((med >> i) & 1) == 1 ) {
                    pos = dp[pos][i];
                }
            }

            if(pos >= b) {
                ub = med;
            }
            else {
                lb = med;
            }
        }

        cout << ub << endl;
    }


    return 0;
}

Measured memory_bytes: 25856