#include <bits/stdc++.h>
const int maxn = 1e5 + 10;
using namespace std;
long long gcd(long long p, long long q) { return q == 0 ? p : gcd(q, p % q); }
long long qpow(long long p, long long q) {
  long long f = 1;
  while (q) {
    if (q & 1) f = f * p;
    p = p * p;
    q >>= 1;
  }
  return f;
}
int n, m, k, t, l[maxn], r[maxn];
long long a[maxn], p;
void init() {
  for (int i = 0; i <= n - 1; i++) {
    r[i] = lower_bound(a, a + n, a[i] + p) - a;
    if (r[i] == n || a[r[i]] > a[i] + p) r[i]--;
    l[i] = lower_bound(a, a + n, a[i] - p) - a;
  }
}
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 0; i <= n - 1; i++) scanf("%lld", &a[i]);
  scanf("%lld", &p);
  init();
  int q;
  scanf("%d", &q);
  while (q--) {
    int b, c, ans = 0;
    scanf("%d%d", &b, &c);
    b--, c--;
    if (b < c) {
      ans = 0;
      while (b < c) ans++, b = r[b];
    } else {
      ans = 0;
      while (b > c) ans++, b = l[b];
    }
    printf("%d\n", ans);
  }
  return 0;
}
