#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, l, q;
int x[100005];
int d[100005][20];
int pw2[25];
inline int CanGoTo(int pos) { return upper_bound(x, x + n, pos + l) - x - 1; }
int solve(int st, int ed) {
  if (st == ed) return 0;
  int x = 0, edp = 0, ok = false;
  for (int i = 18; i >= 1; i--) {
    if (d[st][i] <= ed) {
      x = i;
      edp = d[st][i];
      ok = true;
      break;
    }
  }
  if (!ok) {
    return 1;
  }
  return pw2[x] + solve(edp, ed);
}
int main(int argc, char* argv[]) {
  pw2[0] = 1;
  for (int i = 1; i <= 20; i++) {
    pw2[i] = pw2[i - 1] * 2;
  }
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  cin >> l >> q;
  for (int i = 0; i < n; i++) {
    d[i][1] = CanGoTo(x[i]);
  }
  for (int i = 2; i <= 18; i++) {
    for (int j = 0; j < n; j++) {
      d[j][i] = d[d[j][i - 1]][i - 1];
    }
  }
  for (int i = 0; i < q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    cout << solve(a, b) / 2 << endl;
  }
  return 0;
}
