#include <bits/stdc++.h>
using namespace std;
const long long INF =
    sizeof(long long) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const long long MOD = (long long)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
using pii = pair<long long, long long>;
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}
template <typename T>
void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  for (long long i = (0); i < (v.size()); i++)
    for (long long j = (0); j < (v[i].size()); j++) {
      if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
        cerr << "INF";
      } else
        cerr << v[i][j];
      cerr << (j == v[i].size() - 1 ? '\n' : ' ');
    }
  cerr << endl;
}
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
long long doubling[101010][35];
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  long long N;
  cin >> N;
  vector<long long> x(N);
  for (long long i = (0); i < (N); i++) {
    cin >> x[i];
  }
  long long L;
  cin >> L;
  long long Q;
  cin >> Q;
  vector<long long> a(Q), b(Q);
  for (long long i = (0); i < (Q); i++) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    if (a[i] > b[i]) swap(a[i], b[i]);
  }
  memset(doubling, 0xff, sizeof(doubling));
  for (long long i = (0); i < (N); i++) {
    long long idx = upper_bound(x.begin() + i, x.end(), x[i] + L) - x.begin();
    idx--;
    doubling[i][0] = (idx == i ? INF : idx);
    ;
  }
  for (long long n = (1); n < (35); n++) {
    for (long long i = (0); i < (N); i++) {
      if (doubling[i][n - 1] == INF) {
        doubling[i][n] = INF;
      } else
        doubling[i][n] = doubling[doubling[i][n - 1]][n - 1];
    }
  }
  return 0;
}
