#include <bits/stdc++.h>
using namespace std;
const int mod = 1e4 + 7;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
int a[100010];
int main() {
  int n, L, q;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  scanf("%d%d", &L, &q);
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    if (l > r) swap(l, r);
    l--;
    r--;
    int ans = 0;
    while (1) {
      l = upper_bound(a + l, a + n, a[l] + L) - a - 1;
      ans++;
      if (l >= r) break;
    }
    printf("%d\n", ans);
  }
  return 0;
}
