#include <bits/stdc++.h>
using namespace std;
int r[17][100001];
int solve(int a, int b) {
  int res = 0;
  for (int i = 16; i >= 0; i--) {
    if (r[i][a] > b) continue;
    res += (1 << i);
    a = r[i][a];
  }
  return res;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++) cin >> x[i];
  int l, q;
  cin >> l >> q;
  for (int i = 0; i < n; i++) {
    r[0][i] = (int)(upper_bound(x.begin(), x.end(), x[i] + l) - x.begin()) - 1;
  }
  for (int k = 0; k < 16; k++) {
    for (int i = 0; i < n; i++) {
      r[k + 1][i] = r[k][r[k][i]];
    }
  }
  for (int i = 0; i < q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    cout << solve(a, b) << "\n";
  }
  return 0;
}
