#include <bits/stdc++.h>
const int N = 2e5 + 100;
using namespace std;
int a[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  while (cin >> n) {
    for (int i = 1; i <= n; i++) cin >> a[i];
    int L;
    cin >> L;
    int q;
    cin >> q;
    while (q--) {
      int x, y;
      cin >> x >> y;
      if (x > y) swap(x, y);
      int ans = 0;
      for (int i = x; i <= y; i++) {
        int l = i, r = y;
        int pos = i;
        while (l <= r) {
          int mid = (l + r) / 2;
          if (a[mid] - a[i] > L)
            r = mid - 1;
          else if (a[mid] == L + a[i]) {
            pos = mid;
            break;
          } else
            l = mid + 1, pos = mid;
        }
        ans++;
        if (pos == y) break;
        i = pos - 1;
      }
      cout << ans << endl;
    }
  }
  return 0;
}
