#include <bits/stdc++.h>
using namespace std;
long long n, l, q, a, b, v[100010][32], w[100010][32];
vector<long long> x;
int main() {
  cin >> n;
  x.resize(n + 2);
  for (int i = 1; i <= n; ++i) cin >> x[i];
  x[0] = -1;
  x[n] = 1e9 + 7;
  cin >> l;
  for (int i = 0; i < n; ++i) {
    v[i][0] = upper_bound(x.begin(), x.end(), x[i] + l) - x.begin() - 1;
    w[i][0] = lower_bound(x.begin(), x.end(), x[i] - l) - x.begin();
  }
  for (int i = 1; i < 32; ++i)
    for (int j = 1; j <= n; ++j) v[j][i] = v[v[j][i - 1]][i - 1];
  for (int i = 1; i < 32; ++i)
    for (int j = 1; j <= n; ++j) w[j][i] = w[w[j][i - 1]][j - 1];
  cin >> q;
  while (q--) {
    cin >> a >> b;
    long long ans = 0;
    if (a < b) {
      while (a < b) {
        for (int i = 0; i < 32; ++i) {
          if (v[a][i] == b || (i == 0 && v[a][i] > b)) {
            a = v[a][i];
            ans += 1ll << i;
            break;
          } else if (v[a][i] > b) {
            a = v[a][i - 1];
            ans += 1ll << (i - 1);
            break;
          }
        }
      }
    } else {
      while (b < a) {
        for (int i = 0; i < 32; ++i) {
          if (w[a][i] == b || (i == 0 && w[a][i] < b)) {
            a = w[a][i];
            ans += 1ll << i;
            break;
          } else if (w[a][i] < b) {
            a = w[a][i - 1];
            ans += 1ll << (i - 1);
            break;
          }
        }
      }
    }
    cout << ans << "\n";
  }
}
