#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
signed main() {
  long long num = 0;
  long long N;
  long long L, Q;
  vector<long long> x;
  vector<vector<long long>> table;
  cin >> N;
  x.resize(N);
  for (long long n = N; n > 0; n >>= 1, num++)
    ;
  table.resize(num + 2, vector<long long>(N));
  for (long long i = 0; i < N; i++) {
    cin >> x[i];
  }
  cin >> L >> Q;
  for (long long i = 0; i < N; i++) {
    table[0][i] = upper_bound(x.begin(), x.end(), x[i] + L) - x.begin() - 1;
  }
  for (long long i = 1; i < (long long)table.size(); i++) {
    for (long long j = 0; j < N; j++) {
      table[i][j] = table[i - 1][table[i - 1][j]];
    }
  }
  for (long long i = 0; i < Q; i++) {
    long long a, b;
    long long ans = 0;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    for (long long k = table.size() - 1; k >= 0; k--) {
      if (table[k][a] <= b) {
        a = table[k][a];
        ans += 1 << k;
      }
    }
    if (a != b) ans++;
    cout << ans << endl;
  }
  return 0;
}
