#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30);
const long long INFLL = (1ll << 60);
const long long MOD = (long long)(1e9 + 7);
void mul_mod(long long& a, long long b) {
  a *= b;
  a %= MOD;
}
void add_mod(long long& a, long long b) {
  a = (a < MOD) ? a : (a - MOD);
  b = (b < MOD) ? b : (b - MOD);
  a += b;
  a = (a < MOD) ? a : (a - MOD);
}
int db[100100][25];
long long x[100100];
int main(void) {
  int n, i, j = 0, q, a, b, ans;
  long long l;
  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> x[i];
  }
  cin >> l;
  for (i = 0; i < n; ++i) {
    while (j + 1 < n && x[j + 1] - x[i] <= l) {
      ++j;
    }
    db[i][0] = j;
  }
  for (j = 0; j < 20; ++j) {
    for (i = 0; i < n; ++i) {
      db[i][j + 1] = db[db[i][j]][j];
    }
  }
  cin >> q;
  for (i = 0; i < q; ++i) {
    cin >> a >> b;
    --a;
    --b;
    if (a > b) {
      swap(a, b);
    }
    ans = 0;
    for (j = 20; j >= 0; --j) {
      if (db[a][j] <= b) {
        ans += (1 << j);
        a = db[a][j];
      }
      if (a == b) {
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
