#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 20;
const int maxm = 10e5 + 10;
int bz[maxn + 10][20 + 1], x[maxm], L, n;
long long cnt;
void init() {
  for (int i = 1; i <= n; i++) {
    int t = upper_bound(x + 1, x + 1 + n, x[i] + L) - x;
    bz[i][0] = t - 1;
  }
  for (int j = 1; (1 << j) <= maxn; j++)
    for (int i = 1; i + (1 << j) - 1 <= n; i++)
      bz[i][j] = bz[bz[i][j - 1]][j - 1];
}
int pw(int n) {
  int ans = 1;
  while (n--) ans *= 2;
  return ans;
}
void query(int l, int r) {
  if (l > r) swap(l, r);
  if (l == r) return;
  for (int j = 20; j >= 0; j--) {
    if (!x[bz[l][j]]) continue;
    if (bz[l][j] <= r) {
      cnt += 1 << j;
      query(bz[l][j], r);
      return;
    } else if (bz[l][j] == r) {
      cnt += 1 << j;
      return;
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
  scanf("%d", &L);
  init();
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    cnt = 0;
    query(l, r);
    printf("%lld\n", cnt);
  }
  return 0;
}
