#include <bits/stdc++.h>
using namespace std;
bool test = 0;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
unsigned long long mod = (int)1e9 + 7;
int N;
int x[(int)1e6 + 5];
int L, Q;
int a[(int)1e6 + 5], b[(int)1e6 + 5];
int main() {
  int i, j, k, l;
  cin >> N;
  for (i = 0; i < N; ++i) {
    cin >> x[i];
  }
  cin >> L >> Q;
  if (N > 1000 || Q > 1000) return 0;
  for (i = 0; i < Q; ++i) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    int cnt = 0;
    if (a[i] < b[i]) {
      int now = a[i];
      while (now < b[i]) {
        for (j = now; j < N; j++) {
          if (x[now] + L < x[j]) break;
        }
        now = j - 1;
        cnt++;
      }
    } else {
      int now = a[i];
      while (now > b[i]) {
        for (j = now; j > -1; j--) {
          if (x[now] - L > x[j]) break;
        }
        now = j + 1;
        cnt++;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
