#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int dp[30][MAXN], a[MAXN], l, n;
int q;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  cin >> l;
  for (int i = 1; i <= n; ++i)
    dp[0][i] = upper_bound(a + 1, a + n + 1, a[i] + l) - a - 1;
  for (int i = 1; i < 30; ++i) {
    for (int j = 1; j <= n; ++j) dp[i][j] = dp[i - 1][dp[i - 1][j]];
  }
  cin >> q;
  int a, b, res;
  while (q--) {
    res = 0;
    cin >> a >> b;
    if (a > b) swap(a, b);
    for (int i = 29; i >= 0; --i) {
      if (dp[i][a] == 0) continue;
      if (dp[i][a] < b) {
        a = dp[i][a];
        res += (1 << i);
      } else if (dp[i][a] == b) {
        res += (1 << i);
        break;
      }
    }
    cout << res << endl;
  }
  return 0;
}
