#include <bits/stdc++.h>
using namespace std;
typedef vector<vector<long long> > Matrix;
const long long INF = 100000000000;
Matrix dist;
bool warshall_floyd(int n) {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dist[i][k] != INF && dist[k][j] != INF) {
          dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (dist[i][i] < 0) return true;
  }
  return false;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> x(n);
  for (int i = 0; i < n; i++) cin >> x[i];
  int l, q;
  cin >> l >> q;
  dist = Matrix(n, vector<long long>(n, INF));
  for (int i = 0; i < n; i++) dist[i][i] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (x[j] - x[i] <= l) {
        dist[i][j] = 1;
        dist[j][i] = 1;
      }
    }
  }
  warshall_floyd(n);
  for (int i = 0; i < q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    cout << dist[a][b] << "\n";
  }
  return 0;
}
