#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B>
bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-7;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main() {
  int n;
  cin >> n;
  vector<int> in(n);
  for (int i = 0; i < n; i++) cin >> in[i];
  int l;
  cin >> l;
  vector<vector<int> > dp(40, vector<int>(n));
  for (int i = 0; i < n; i++)
    dp[0][i] = upper_bound(in.begin(), in.end(), in[i] + l) - in.begin() - 1;
  for (int i = 0; i < 39; i++)
    for (int j = 0; j < n; j++) dp[i + 1][j] = dp[i][dp[i][j]];
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    long long sum = 0, out = inf;
    for (int i = 39; i >= 0; i--) {
      int t = dp[i][a];
      if (t == b) {
        sum += 1 << i;
        cout << sum << endl;
        goto end;
      } else if (t < b) {
        sum += 1 << i;
        a = t;
      } else
        out = min(out, (1ll << i) + sum);
    }
    cout << out << endl;
  end:;
  }
}
