#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, x[maxn], nxt[maxn][18], q, l;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
  scanf("%d", &l);
  for (int i = 1; i <= n; i++)
    nxt[i][0] = upper_bound(x + 1, x + 1 + n, x[i] + l) - x - 1;
  for (int i = 1; i <= 17; i++)
    for (int j = 1; j <= n; j++) nxt[j][i] = nxt[nxt[j][i - 1]][i - 1];
  scanf("%d", &q);
  while (q--) {
    int a, b, ans = 0;
    scanf("%d %d", &a, &b);
    if (a > b) swap(a, b);
    for (int i = 17; i >= 0; i--)
      if (nxt[a][i] <= b) {
        a = nxt[a][i];
        ans += (1 << i);
      }
    printf("%d\n", ans);
  }
  return 0;
}
