#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
int N;
int main() {
  cin >> N;
  vector<int> x(N);
  int y[18][100005];
  for (int i = 0; i < (int)(N); i++) {
    cin >> x.at(i);
  }
  int L;
  cin >> L;
  int pos = 1;
  for (int i = 0; i < (int)(N); i++) {
    while (pos < N && x.at(pos) <= x.at(i) + L) {
      pos++;
    }
    y[0][i + 1] = pos;
  }
  for (int i = 0; i < 18; i++) {
    for (int j = 1; j <= N; j++) {
      y[i + 1][j] = y[i][y[i][j]];
    }
  }
  int Q;
  cin >> Q;
  while (Q > 0) {
    Q--;
    int ans = 0;
    int a, b;
    cin >> a >> b;
    if (a > b) {
      int tmp = b;
      b = a;
      a = tmp;
    }
    int now = a;
    while (now < b) {
      int base = 1;
      int i = 0;
      while (y[i][now] < b) {
        i++;
        base *= 2;
      }
      if (i >= 1) {
        now = y[i - 1][now];
        ans += base / 2;
      } else {
        now = b;
        ans += base;
      }
    }
    cout << ans << endl;
  }
}
