#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int x[N];
  for (int i = 0; i < (int)(N); i++) cin >> x[i];
  long long L;
  cin >> L;
  int logN = (int)log2(N);
  int doub[N][logN];
  fill(doub[0], doub[N], -1);
  for (int i = 0; i < (int)(N - 1); i++)
    doub[i][0] = upper_bound(x, x + N, x[i] + L) - x - 1;
  for (int i = 0; i < (int)(logN); i++)
    for (int j = 0; j < (int)(N); j++)
      if (doub[j][i] != -1) doub[j][i + 1] = doub[doub[j][i]][i];
  int q;
  cin >> q;
  for (int i = 0; i < (int)(q); i++) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    a--;
    b--;
    int ans = 0;
    for (int i = logN - 1; i >= 0; i--) {
      if (doub[a][i] == -1) continue;
      if (doub[a][i] <= b) {
        ans += 1 << i;
        a = doub[a][i];
      }
    }
    cout << (a == b ? ans : ans + 1) << endl;
  }
  return 0;
}
