#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100005;
const int inf = 0x3f3f3f3f;
int n, a[Maxn], L, q;
int nxt[Maxn], nxt2[Maxn][20];
void init() {
  for (int l = 1, r = 1; l <= n && r <= n && a[r] - a[l] <= L; ++l) {
    while (r <= n && a[r] - a[l] <= L) r++;
    r--;
    nxt[l] = r;
  }
  nxt[n] = inf;
  for (int i = 1; i <= n; ++i) nxt2[i][0] = nxt[i];
  for (int i = 1; i <= 18; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (nxt2[j][i - 1] == inf)
        nxt2[j][i] = inf;
      else
        nxt2[j][i] = nxt2[nxt2[j][i - 1]][0];
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  cin >> L >> q;
  init();
  while (q--) {
    int x, y;
    cin >> x >> y;
    if (x > y) swap(x, y);
    int l = 0, r = 18, ans = 0;
    while (l <= r) {
      int mid = l + r >> 1;
      if (nxt2[x][mid] > y)
        r = mid - 1;
      else if (nxt2[x][mid] == y) {
        ans = mid;
        break;
      } else
        ans = l = mid + 1;
    }
    cout << ans << endl;
  }
  return 0;
}
