#include <bits/stdc++.h>
using namespace std;
int N;
long long x[100001];
long long L;
long long g[21][100001];
int Q;
long long a[100001];
long long b[100001];
int main() {
  cin >> N;
  for (int(i) = 0; (i) < (int)(N); (i)++) {
    cin >> x[i];
  }
  cin >> L >> Q;
  for (int(i) = 0; (i) < (int)(Q); (i)++) {
    cin >> a[i] >> b[i];
    if (a[i] > b[i]) swap(a[i], b[i]);
    a[i]--;
    b[i]--;
  }
  int now = 0;
  for (int(i) = 0; (i) < (int)(N); (i)++) {
    while (1) {
      if (now == N) break;
      if (x[now] - x[i] <= L) {
        now++;
      } else {
        break;
      }
    }
    g[0][i] = now - 1;
  }
  for (int(i) = 0; (i) < (int)(21); (i)++) {
    if (i == 0) continue;
    for (int(j) = 0; (j) < (int)(N); (j)++) {
      g[i][j] = g[i - 1][g[i - 1][j]];
    }
  }
  for (int(i) = 0; (i) < (int)(Q); (i)++) {
    long long c = 0;
    int cc = a[i];
    while (cc != b[i]) {
      long long d = 1;
      int nxt = 0;
      for (int(j) = 0; (j) < (int)(21); (j)++) {
        if (g[j][cc] == b[i]) break;
        if (g[j][cc] < b[i]) {
          d *= 2;
          nxt++;
        }
      }
      cc = g[nxt][cc];
      c += d;
    }
    cout << c << endl;
  }
  return 0;
}
