#include <bits/stdc++.h>
using namespace std;
long long n, a[100000 + 5], L, t, lgn;
long long ne[100000 + 5];
long long f[100000 + 5][21];
long long divide(long long d) {
  long long l = 1, r = n;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (a[mid] > d) r = mid - 1;
    if (a[mid] <= d) l = mid + 1;
  }
  return r;
}
int main() {
  scanf("%lld", &n);
  lgn = log2(n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  scanf("%lld%lld", &L, &t);
  for (int i = 1; i <= n; i++) {
    long long x = divide(a[i] + L);
    f[i][0] = x;
  }
  for (int j = 1; j <= lgn; j++) {
    for (int i = 1; i <= n; i++) {
      f[i][j] = f[f[i][j - 1]][j - 1];
    }
  }
  for (int i = 1; i <= t; i++) {
    long long times = 0;
    long long u, v;
    scanf("%lld%lld", &u, &v);
    if (u > v) swap(u, v);
    for (int j = lgn; j >= 0; j--) {
      if (f[u][j] < v) {
        u = f[u][j];
        times = times + j + 1;
      }
    }
    times++;
    printf("%lld\n", times);
  }
  return 0;
}
