#include <bits/stdc++.h>
using namespace std;
template <class T>
void show(const vector<T> &a) {
  for (T x : a) cout << x << " ";
  cout << '\n';
}
vector<long long> xx = {1, 0, -1, 0};
vector<long long> yy = {0, 1, 0, -1};
string dir = "LRUD";
const long long N = 2e5 + 50, oo = 5e18 + 500;
const long long mod = 998244353;
const long double eps = 1e-6, PI = 2 * acos(0.0);
long long n, m, k;
long long cnt = 0;
long long lg = 18;
vector<long long> g[N];
vector<long long> rg[N];
vector<long long> visit(N, 0);
signed main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  cin >> n;
  vector<long long> x(n);
  for (long long i = 0; i < n; i++) {
    cin >> x[i];
  }
  cin >> m >> k;
  vector<vector<long long> > dp(n, vector<long long>(lg, n - 1));
  for (long long i = 0; i < n - 1; i++) {
    dp[i][0] = upper_bound(x.begin(), x.end(), x[i] + m) - x.begin() - 1;
  }
  for (long long j = 1; j < lg; j++) {
    for (long long i = 0; i < n - 1; i++) {
      dp[i][j] = dp[dp[i][j - 1]][j - 1];
    }
  }
  while (k--) {
    long long l, r;
    cin >> l >> r;
    l--;
    r--;
    if (l > r) swap(l, r);
    cnt = 0;
    for (long long j = lg - 1; j >= 0; j--) {
      if (dp[l][j] <= r) {
        l = dp[l][j];
        cnt += (1 << j);
      }
    }
    cout << cnt << '\n';
  }
}
