#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < (int)n; ++i) {
    int a;
    cin >> x[i];
  }
  int l, q;
  cin >> l >> q;
  vector<vector<int> > dp(30, vector<int>(100005, 0));
  for (int i = 0; i < (int)n; ++i) {
    auto it = upper_bound((x).begin(), (x).end(), x[i] + l);
    it--;
    dp[0][i] = it - x.begin();
  }
  for (int i = (int)(1); i < (int)(30); ++i) {
    for (int j = 0; j < (int)n; ++j) {
      dp[i][j] = dp[i - 1][dp[i - 1][j]];
    }
  }
  for (int i = 0; i < (int)q; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int ans = 0;
    for (int i = n - 1; i >= 0; --i) {
      if (dp[i][a] < b) {
        a = dp[i][a];
        ans += 1 << i;
      }
    }
    cout << ans + 1 << endl;
  }
  return 0;
}
