#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 2e5 + 5;
int n, q, L;
long long f[kMaxN][31], x[kMaxN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", x + i);
  }
  scanf("%d%d", &L, &q);
  for (int i = 1; i <= n; ++i) {
    f[i][0] = upper_bound(x + 1, x + n + 1, x[i] + L) - x - 1;
  }
  for (int j = 1; j <= 30; ++j)
    for (int i = 1; i <= n; ++i) {
      f[i][j] = f[f[i][j - 1]][j - 1];
    }
  for (int i = 1; i <= q; ++i) {
    int l, r;
    scanf("%d%d", &l, &r);
    if (l > r) swap(l, r);
    long long ans = 0;
    for (int j = 30; j >= 0; --j) {
      if (f[l][j] <= r) {
        ans += 1LL << j;
        l = f[l][j];
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}
