#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1, ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int MAXN = 100000 + 10;
int n, x[MAXN], f[MAXN][35];
int binary_search(int k) {
  int l = 1, r = n;
  while (l < r) {
    int mid = (l + r + 1) >> 1;
    if (x[mid] <= k)
      l = mid;
    else
      r = mid - 1;
  }
  return r;
}
int main() {
  n = read();
  for (register int i = 1; i <= n; i++) x[i] = read();
  int l = read(), q = read();
  for (register int i = 1; i <= n; i++) f[i][0] = binary_search(x[i] + l);
  for (register int j = 1; j <= 30; j++)
    for (register int i = 1; i <= n; i++) f[i][j] = f[f[i][j - 1]][j - 1];
  while (q--) {
    int a = read(), b = read();
    if (a > b) swap(a, b);
    int ans = 0;
    for (register int i = 30; i >= 0; i--) {
      if (f[a][i] < b) a = f[a][i], ans += (1 << i);
    }
    printf("%d\n", ans + 1);
  }
}
