#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long long linf = 1LL << 62;
const int MAX = 510000;
long long dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};
long long dx[8] = {0, 0, 1, -1, 1, -1, -1, 1};
const double pi = acos(-1);
const double eps = 1e-7;
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <typename T>
inline void print(T &a) {
  for (long long i = 0; i < (a.size()); i++) cout << a[i] << " ";
  cout << "\n";
}
template <typename T1, typename T2>
inline void print2(T1 a, T2 b) {
  cout << a << " " << b << "\n";
}
template <typename T1, typename T2, typename T3>
inline void print3(T1 a, T2 b, T3 c) {
  cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
int main() {
  long long n;
  cin >> n;
  vector<long long> x(n);
  for (long long i = 0; i < (n); i++) cin >> x[i];
  long long l, q;
  cin >> l >> q;
  vector<vector<long long> > nxt(20, vector<long long>(n + 1, inf));
  for (long long i = 0; i < (n); i++) {
    nxt[0][i] = upper_bound((x).begin(), (x).end(), x[i] + l) - x.begin();
    nxt[0][i]--;
  }
  for (long long k = 0; k < (20); k++) nxt[k][n] = n;
  for (long long k = 0; k < (19); k++) {
    for (long long i = 0; i < (n); i++) {
      nxt[k + 1][i] = nxt[k][nxt[k][i]];
    }
  }
  while (q--) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    long long now = a, ans = 0;
    for (int lg = 19; lg >= 0; lg--) {
      if (nxt[lg][now] < b) {
        ans += 1 << lg;
        now = nxt[lg][now];
      } else if (nxt[lg][now] == b) {
        if (lg == 0 || nxt[lg - 1][now] < b) {
          ans += 1 << lg;
          break;
        }
      }
    }
    cout << ans << endl;
  }
}
