#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < (n); i++) cin >> x[i];
  int l;
  cin >> l;
  const int INF = 1e6;
  vector<vector<int>> table(n, vector<int>(20, INF));
  int r = 0;
  for (int i = 0; i < (n); i++) {
    while (1) {
      if (r == n - 1) break;
      if (x[r + 1] - x[i] <= l)
        r++;
      else
        break;
    }
    table[i][0] = r;
  }
  for (int j = 0; j < (19); j++)
    for (int i = 0; i < (n); i++) {
      if (table[i][j] == INF)
        table[i][j + 1] = INF;
      else
        table[i][j + 1] = table[table[i][j]][j];
    }
  vector<int> p(20);
  p[0] = 1;
  for (int i = 0; i < (19); i++) p[i + 1] = p[i] * 2;
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    int ans = 0;
    while (1) {
      int idx =
          lower_bound(table[a].begin(), table[a].end(), b) - table[a].begin();
      if (table[a][idx] == b) {
        ans += p[idx];
        break;
      } else {
        a = table[a][idx - 1];
        ans += p[idx - 1];
      }
    }
    cout << ans << endl;
  }
}
