#include <bits/stdc++.h>
using namespace std;
int r[18][100000];
int main() {
  int n, L;
  cin >> n;
  vector<int> x(n);
  for (int(i) = 0; (i) < (int)(n); ++(i)) scanf(" %d", &x[i]);
  cin >> L;
  for (int(i) = 0; (i) < (int)(n); ++(i))
    r[0][i] = upper_bound((x).begin(), (x).end(), x[i] + L) - x.begin() - 1;
  for (int i = 1; i < 18; ++i)
    for (int(j) = 0; (j) < (int)(n); ++(j)) r[i][j] = r[i - 1][r[i - 1][j]];
  int Q;
  cin >> Q;
  for (int(q) = 0; (q) < (int)(Q); ++(q)) {
    int a, b;
    scanf(" %d %d", &a, &b);
    --a;
    --b;
    if (a > b) swap(a, b);
    int ans = 0;
    int now = a;
    for (int i = 17; i > 0; --i) {
      if (r[i][now] < b) {
        now = r[i][now];
        ans += 1 << i;
      }
    }
    if (now < b) {
      now = r[0][now];
      ++ans;
    }
    printf("%d\n", ans);
  }
  return 0;
}
