#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;
ll gcd(ll a, ll b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll modpow(ll x, ll y) {
  ll res = 1;
  while (y) {
    if (y % 2) {
      res *= x;
      res %= mod;
    }
    x = x * x % mod;
    y /= 2;
  }
  return res;
}
ll G[12345678], test[12345678];
signed main() {
  ll n, l, q, a, b;
  cin >> n;
  for (int h = 0; h < n; h++) {
    cin >> test[h];
  }
  cin >> l >> q;
  ll mae = -1, ato = 0;
  while (true) {
    if (mae == n - 1) {
      break;
    }
    mae++;
    while (true) {
      if (ato != n - 1 && test[ato + 1] - test[mae] <= l) {
        ato++;
      } else {
        break;
      }
    }
    G[mae + 1] = ato + 1;
  }
  vector<vector<ll>> v(n + 5);
  vector<ll> oya(n + 1), visit(n + 1);
  for (int h = 1; h < n; h++) {
    if (visit[h] == 0) {
      ll cnt = h;
      visit[cnt] = 1;
      oya[cnt] = h;
      v[h].push_back(cnt);
      while (true) {
        cnt = G[cnt];
        visit[cnt] = 1;
        oya[cnt] = h;
        v[h].push_back(cnt);
        if (cnt == n) {
          break;
        }
      }
    }
  }
  for (int h = 0; h < q; h++) {
    cin >> a >> b;
    if (a > b) {
      swap(a, b);
    }
  }
  return 0;
}
