#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = MOD + 1;
const long double EPS = 1e-12;
template <class T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <class T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
long long toleft[111111][50], toright[111111][50];
int main() {
  cin.sync_with_stdio(false);
  cout << fixed << setprecision(10);
  long long n, l, q;
  cin >> n;
  vector<int> x(n);
  for (int i = (int)(0); i < (int)(n); i++) cin >> x[i];
  cin >> l;
  memset(toleft, 0, sizeof(toleft));
  memset(toright, 0, sizeof(toright));
  for (int i = (int)(0); i < (int)(n); i++) {
    long long lp = x[i] - l;
    if (lp <= x[0])
      toleft[i][0] = 0;
    else {
      toleft[i][0] = lower_bound(x.begin(), x.end(), lp) - x.begin();
    }
    long long rp = x[i] + l;
    if (rp >= x[n - 1])
      toright[i][0] = n - 1;
    else {
      toright[i][0] = upper_bound(x.begin(), x.end(), rp) - x.begin() - 1;
    }
  }
  for (int j = (int)(1); j < (int)(50); j++)
    for (int i = (int)(0); i < (int)(n); i++) {
      toleft[i][j] = toleft[toleft[i][j - 1]][j - 1];
      toright[i][j] = toright[toright[i][j - 1]][j - 1];
    }
  cin >> q;
  while (q--) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    long long ans = 0, p = a;
    if (a < b) {
      while (p != b) {
        if (toright[p][0] >= b) {
          p = toright[p][0];
          ans++;
        } else {
          for (int i = 32; i >= 0; i--) {
            if (toright[p][i] < b) {
              p = toright[p][i];
              ans += pow(2, i);
              break;
            }
          }
        }
      }
    } else {
      while (p != b) {
        if (toright[p][0] >= b) {
          p = toright[p][0];
          ans++;
        } else {
          for (int i = 32; i >= 0; i--) {
            if (toleft[p][i] > b) {
              p = toleft[p][i];
              ans += pow(2, i);
              break;
            }
            if (i == 0) {
              p = b;
              ans++;
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
