#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000000 + 7;
const long long hmod1 = 999999937;
const long long hmod2 = 1000000000 + 9;
const long long INF = 1 << 30;
const long long dx4[4] = {1, 0, -1, 0};
const long long dy4[4] = {0, 1, 0, -1};
const long long dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const long long dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;
long long n, l, q;
vector<long long> x(100000 + 5, 1e10);
vector<vector<long long>> step(100000 + 5, vector<long long>(25, 1e10));
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  for (long long i = 0; i < (n); i++) cin >> x[i];
  cin >> l;
  for (long long i = 0; i < (n); i++) {
    long long nx =
        lower_bound((x).begin(), (x).end(), x[i] + l + 1) - 1 - x.begin();
    step[i][0] = nx;
  }
  for (long long j = 0; j < (20); j++)
    for (long long i = 0; i < (n); i++) {
      step[i][j + 1] = step[step[i][j]][j];
    }
  cin >> q;
  for (long long i = 0; i < (q); i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    long long ans = 0;
    long long now = a;
    while (now < b) {
      long long d = lower_bound((step[now]).begin(), (step[now]).end(), b + 1) -
                    1 - step[now].begin();
      ans += (long long)pow(2, d);
      now = step[now][d];
    }
    cout << ans << endl;
  }
}
