#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
int main() {
  int n, l, q, x[112345], a[112345], b[112345];
  int root[112345];
  int cld[112345];
  cin >> n;
  for (int i = (0); i < (n); i++) cin >> x[i];
  cin >> l >> q;
  for (int 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(cld, -1, sizeof(cld));
  memset(root, -1, sizeof(root));
  for (int i = 0; i < n; i++) {
    if (root[i] != -1) continue;
    root[i] = i;
    int cur = i;
    int j = i + 1;
    while (j < n) {
      if (x[j + 1] - x[cur] > l || j == n - 1) {
        cld[cur] = j;
        if (root[j] != -1) break;
        root[j] = i;
        cur = j;
      }
      j++;
    }
  }
  vector<int> sum[112345];
  bool used[112345];
  fill(used, used + n, false);
  for (int i = 0; i < n; i++) {
    int r = root[i];
    if (used[r]) continue;
    used[r] = true;
    sum[r].push_back(0);
    int j = i;
    while (true) {
      if (j == n - 1) break;
      int nex = cld[j];
      sum[r].push_back(sum[r][sum[r].size() - 1] + x[nex] - x[j]);
      j = nex;
    }
  }
  for (int i = (0); i < (q); i++) {
    int rt = root[a[i]];
    int d = x[b[i]] - x[a[i]];
    int l = 0, r = sum[rt].size();
    while (r - l > 1) {
      int mid = (r + l) / 2;
      if (sum[rt][mid] >= d + (x[a[i]] - x[rt]))
        r = mid;
      else
        l = mid;
    }
    int l_ = -1, r_ = sum[rt].size();
    while (r_ - l_ > 1) {
      int mid = (r_ + l_) / 2;
      if (sum[rt][mid] >= (x[a[i]] - x[rt]))
        r_ = mid;
      else
        l_ = mid;
    }
    cout << r - r_ << endl;
  }
  return 0;
}
