#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long double EPS = 1e-8;
int main() {
  int N, L, Q;
  cin >> N;
  vector<int> x(N);
  for (int i = 0; i < (int)(N); i++) cin >> x[i];
  cin >> L >> Q;
  vector<vector<int>> r(20, vector<int>(N));
  for (int i = 0; i < (int)(N); i++) {
    r[0][i] = upper_bound((x).begin(), (x).end(), x[i] + L) - x.begin() - 1;
  }
  for (int k = 0; k < (int)(19); k++)
    for (int i = 0; i < (int)(N); i++) r[k + 1][i] = r[k][r[k][i]];
  for (int i = 0; i < (int)(Q); i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    if (a > b) swap(a, b);
    int res = 0;
    while (a < b) {
      for (int j = 0; j < (int)(19); j++)
        if (r[j][a] <= b && r[j + 1][a] > b) {
          res += (1 << j);
          a = r[j][a];
          break;
        }
    }
    cout << res << endl;
  }
  return 0;
}
