#include <bits/stdc++.h>
using namespace std;
int n, l, q;
int nx[20][100010];
int main(void) {
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < (n); i++) cin >> x[i];
  cin >> l >> q;
  for (int j = 0; j < n; ++j) {
    nx[0][j] = upper_bound(x.begin(), x.end(), x[j] + l) - x.begin() - 1;
  }
  for (int i = 1; i < 20; ++i) {
    for (int j = 0; j < n; ++j) {
      nx[i][j] = nx[i - 1][nx[i - 1][j]];
    }
  }
  for (int k = 0; k < q; ++k) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    if (b < a) swap(a, b);
    int ans = 0;
    int now = a;
    for (int i = 19; i >= 0; --i) {
      if (nx[i][a] < b) {
        now = nx[i][now];
        ans += 1 << i;
      }
    }
    cout << ans + 1 << endl;
  }
}
