#include <bits/stdc++.h>
using namespace std;
long long a[100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long l;
  cin >> l;
  int q;
  cin >> q;
  while (q--) {
    int a1, b;
    cin >> a1 >> b;
    if (a1 <= b) {
      int start = a1, cnt = 0;
      while (start < b) {
        int id = lower_bound(a + 1, a + 1 + n, a[start] + l) - a;
        if (a[id] > a[start] + l) {
          id--;
        }
        start = id;
        cnt++;
      }
      cout << cnt << "\n";
    } else {
      int start = a1, cnt = 0;
      while (start > b) {
        int id = lower_bound(a + 1, a + 1 + n, a[start] - l) - a;
        if (a[id] < a[start] - l) {
          id++;
        }
        start = id;
        cnt++;
      }
      cout << cnt << "\n";
    }
  }
}
