#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
bool prime(long long x) {
  for (long long i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) return false;
  }
  return true;
}
long long kai(long long x, long long y) {
  long long res = 1;
  for (long long i = x - y + 1; i <= x; i++) {
    res *= i;
    res %= 1000000007;
  }
  return res;
}
long long mod_pow(long long x, long long y, long long m) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) {
      res = res * x % m;
    }
    x = x * x % m;
    y >>= 1;
  }
  return res;
}
long long comb(long long x, long long y) {
  if (y > x) return 0;
  return kai(x, y) * mod_pow(kai(y, y), 1000000007 - 2, 1000000007) %
         1000000007;
}
long long n, x[100010], l, q;
long long nex[20][100010];
long long query_sub(long long s, long long k) {
  for (long long i = log2(n); i >= 0; i--)
    if (k & (1 << i)) s = nex[i][s];
  return s;
}
long long query(long long a, long long b) {
  if (a > b) swap(a, b);
  long long mi = 0, ma = n;
  while (ma - mi > 1) {
    long long md = (mi + ma) / 2;
    if (query_sub(a, md) < b)
      mi = md;
    else
      ma = md;
  }
  return ma;
}
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> x[i];
  cin >> l;
  nex[0][n] = 1145141919810364364;
  long long k = n;
  for (long long i = n - 1; i >= 1; i--) {
    while (x[k] - x[i] > l) k--;
    nex[0][i] = k;
  }
  for (long long i = 1; i < log2(n); i++) {
    for (long long j = n; j >= 1; j--) {
      if (nex[i - 1][j] == 1145141919810364364)
        nex[i][j] = 1145141919810364364;
      else
        nex[i][j] = nex[i - 1][nex[i - 1][j]];
    }
  }
  cin >> q;
  for (long long i = 0; i < q; i++) {
    long long a, b;
    cin >> a >> b;
    cout << query(a, b) << endl;
  }
}
