#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

ll pow2[100];

struct Doubling{
    const int ub_log;               // 要素数の二進表記の桁数
    vector<vector<int>> table;      // ダブリングテーブル

    Doubling(int sz, int64_t lim_t) : ub_log(64 - __builtin_clzll(lim_t)){
        table.assign(ub_log, vector<int>(sz, -1));
    }

    // k番目の要素から1(=2^0)個先の要素をテーブルに埋める
    void set_next(int k, int x){
        table[0][k] = x;
    }

    // ダブリングテーブルの構築
    void build(){
        for(int k = 0; k + 1 < ub_log; ++k){
            for(int i = 0; i < table[k].size(); ++i){
                if(table[k][i] == -1)   table[k+1][i] = -1;
                else    table[k+1][i] = table[k][table[k][i]];
            }
        }
    }

    // k番目から(2^t)個先の要素を返す
    int query(int k, int64_t t){
        for(int i = ub_log - 1; i >= 0; --i){
            if((t >> i) & 1)    k = table[i][k];
        }
        return k;
    }

    ll search(int a, int b){
        ll res = 0;
        bool update = true;
        while(update){
            update = false;
            for(int k = 0; k < ub_log; ++k){
                if(table[k][a] == b){
                    res += pow2[k];
                    break;
                }
                if(table[k][a] > b){
                    if(k == 0){
                        res += pow2[k];
                        break;
                    }
                    else{
                        res += pow2[k-1];
                        a = table[k-1][a];
                        update = true;
                        break;
                    }
                }
                if(table[k][a] == -1){
                    res += pow2[k-1];
                    a = table[k-1][a];
                    update = true;
                    break;
                }
            }
        }
        return res;
    }

    void debug(){
        for(int k = 0; k + 1 < ub_log; ++k){
            for(int i = 0; i < table[k].size(); ++i){
                cerr << table[k][i] << " ";
            }
            cerr << "\n";
        }
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    vector<int> x(n);
    for(int i = 0; i < n; ++i)  cin >> x[i];
    int l, q;
    cin >> l >> q;
    Doubling d(n, x[n-1]);
    for(int i = 0; i < n; ++i){
        int pos = upper_bound(x.begin(), x.end(), x[i] + l) - x.begin();
        if(pos - 1 == i)    continue;
        d.set_next(i, pos - 1);
    }
    d.build();
    pow2[0] = 1;
    ll tmp = 1;
    int cnt = 0;
    while(tmp < x[n-1]){
        tmp *= 2;
        pow2[++cnt] = tmp;
    }
    
    for(int i = 0; i < q; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        if(a > b)   swap(a, b);
        cout << d.search(a, b) << "\n";
    }
}

Measured memory_bytes: 12920