#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int SIZE = 30;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> mov(n + 1, vector<int>(SIZE, 0));
  vector<ll> x(n);
  map<ll, int> pos;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    pos[x[i]] = i;
  }
  pos[1e9 + 1] = n;
  ll l;
  cin >> l;
  for (int i = 0; i < n + 1; i++) mov[i][0] = i;
  for (int i = 0; i < n + 1; i++) {
    if (i != n)
      mov[i][1] = (pos.upper_bound(x[i] + l)->second) - 1;
    else
      mov[i][1] = n;
  }
  for (int i = 1; i + 1 < SIZE; i++) {
    for (int j = 0; j < n + 1; j++) {
      if (j != n)
        mov[j][i + 1] = mov[mov[j][i]][i];
      else
        mov[j][i + 1] = n;
    }
  }
  int q;
  cin >> q;
  for (int loop = 0; loop < q; loop++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    int res = 0;
    while (true) {
      int lb = 0;
      int ub = SIZE;
      while (ub - lb > 1) {
        int mid = (lb + ub) / 2;
        int to = mov[a][mid];
        if (b <= to)
          ub = mid;
        else
          lb = mid;
      }
      if (lb == 0) {
        res++;
        break;
      }
      res += (1 << (lb - 1));
      a = mov[a][lb];
    }
    cout << res << endl;
  }
  return 0;
}
