#include <bits/stdc++.h>
using namespace std;
using namespace std;
int mod = 1000000007;
int powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
int N = 101000;
int n, x[10100], l, q, p[101000][22], u, v;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", x + i);
  scanf("%d", &l);
  for (int i = 0; i < n; i++) p[i][0] = upper_bound(x, x + n, x[i] + l) - x - 1;
  for (int j = 1; j < 20; j++)
    for (int i = 0; i < n; i++) p[i][j] = p[p[i][j - 1]][j - 1];
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d%d", &u, &v);
    --u;
    --v;
    if (u > v) swap(u, v);
    int r = 0;
    for (int j = 20 - 1; j >= 0; j--)
      if (p[u][j] < v) {
        u = p[u][j], r += (1 << j);
      }
    printf("%d\n", r + 1);
  }
}
