#include <bits/stdc++.h>
using namespace std;
const char dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int ar[1000][1000];
int main() {
  int n, l, q;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < (n); i++) cin >> x[i];
  fill(ar[0], ar[1000], (1 << 28));
  for (int i = 0; i < (n); i++) ar[i][i] = 0;
  cin >> l >> q;
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (i); j++) {
      if (x[i] - x[j] <= l) ar[i][j] = ar[j][i] = 1;
    }
  for (int k = 0; k < (n); k++)
    for (int i = 0; i < (n); i++)
      for (int j = 0; j < (n); j++)
        ar[i][j] = min(ar[i][j], ar[i][k] + ar[k][j]);
  while (q--) {
    int a, b;
    cin >> a >> b;
    cout << ar[a - 1][b - 1] << endl;
  }
  return 0;
}
