#include <bits/stdc++.h>
using namespace std;
int n, v[100005], L;
int t[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> v[i];
  }
  cin >> L;
  t[0] = t[1] = 0;
  for (int i = 2; i <= n; ++i) {
    for (int j = 1; j < i; ++j) {
      if (v[i] - v[j] <= L) {
        t[i] = t[j] + 1;
        break;
      }
    }
  }
  int q, a, b;
  cin >> q;
  while (q--) {
    cin >> a >> b;
    if (a > b) {
      swap(a, b);
    }
    if (t[a] == t[b])
      cout << 1 << endl;
    else
      cout << t[b] - t[a] << endl;
  }
}
