#include <bits/stdc++.h>
using namespace std;
int n, l, q, x, y, a[100005], dp[25][100005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  scanf("%d", &l);
  int son = 1;
  for (int i = 1; i <= n; i++) {
    while (a[i] + l >= a[son + 1] && son + 1 <= n) son++;
    dp[0][i] = son;
  }
  for (int p = 1; p <= 20; p++) {
    for (int i = 1; i <= n; i++) {
      dp[p][i] = dp[p - 1][dp[p - 1][i]];
    }
  }
  scanf("%d", &q);
  while (q--) {
    int ans = 0;
    scanf("%d %d", &x, &y);
    if (x > y) swap(x, y);
    for (int p = 20; p >= 0; p--) {
      if (dp[p][x] <= y) {
        ans += (1 << p);
        x = dp[p][x];
      }
    }
    printf("%d\n", ans);
  }
}
