#include <bits/stdc++.h>
using namespace std;
long long x[1005];
long long y[1005];
long long dp[1005][30];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
  }
  long long l;
  cin >> l;
  bool flag = 0;
  for (int i = 1; i <= n; i++) {
    y[i] = upper_bound(x + 1, x + n + 1, x[i] + l) - x - 1;
    dp[i][0] = i;
    dp[i][1] = y[i];
    if (y[i] < n) {
      flag = 1;
    }
  }
  int cnt = 2;
  while (flag) {
    flag = 0;
    int t = 1 << (cnt - 1);
    for (int i = 1; i <= n; i++) {
      dp[i][cnt] = dp[dp[i][cnt - 1]][cnt - 1];
      if (dp[i][cnt] < n) {
        flag = 1;
      }
    }
    cnt++;
  }
  cnt--;
  int q;
  cin >> q;
  for (int aaa = 0; aaa < q; aaa++) {
    int from, to;
    cin >> from >> to;
    if (from > to) {
      swap(from, to);
    }
    int ans = 0;
    int now = from;
    while (now < to) {
      int t = lower_bound(dp[now], dp[now] + cnt, to) - dp[now];
      if (t > 2) {
        t--;
      }
      now = dp[now][t];
      ans += (1 << (t - 1));
    }
    cout << ans << endl;
  }
}
