#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
long mp[maxn];
long long jump[maxn][35];
long long ans;
int main() {
  long long n, l, q, a, b;
  scanf("%lld", &n);
  for (int i = 1; i <= n; ++i) scanf("%lld", &mp[i]);
  scanf("%lld", &l);
  int rmost = 1;
  for (int i = 1; i < n; ++i) {
    while (rmost <= n && mp[rmost] - mp[i] <= l) rmost++;
    jump[i][0] = rmost - 1;
  }
  jump[n][0] = 0;
  for (int j = 1; j <= 30; ++j) {
    for (int i = 1; i <= n; ++i) {
      if (jump[i][j - 1] <= n) jump[i][j] = jump[jump[i][j - 1]][j - 1];
    }
  }
  scanf("%lld", &q);
  for (int i = 1; i <= q; ++i) {
    ans = 0;
    scanf("%lld%lld", &a, &b);
    if (a > b) {
      int t = a;
      a = b;
      b = t;
    }
    int now = a;
    if (jump[now][0] >= b)
      ans = 1;
    else
      for (int i = 30; i >= 0; --i) {
        if (jump[now][i] <= b && jump[now][i] > 0) {
          ans += (1ll << i);
          now = jump[now][i];
          if (now == b) break;
        }
      }
    printf("%lld\n", ans);
  }
  return 0;
}
