#include <bits/stdc++.h>
using namespace std;
const int vx[4] = {0, 1, 0, -1};
const int vy[4] = {1, 0, -1, 0};
long long n, l, q;
vector<long long> a;
map<long long, long long> mp[110000];
long long dir(long long x, long long y) {
  if (x == y) return 0;
  if (mp[x][y]) return mp[x][y];
  long long r = upper_bound(a.begin(), a.end(), a[x] + l) - a.begin();
  r--;
  r = min(r, y);
  return mp[x][y] = 1 + dir(r, y);
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  a = vector<long long>(n);
  for (long long i = (long long)0; i < (long long)n; i++) {
    cin >> a[i];
  }
  cin >> l >> q;
  while (q--) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    if (x > y) swap(x, y);
    cout << dir(x, y) << endl;
  }
}
