#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long long INF = 1ll << 55;
const double pi = acos(-1);
const double eps = 1e-8;
const long long mod = 1e9 + 7;
const vector<int> emp;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, -0};
const int DX[8] = {-1, -1, -1, 0, 0, 1, 1, 1},
          DY[8] = {1, 0, -1, 1, -1, 1, 0, -1};
int n, l, q;
vector<int> a;
int main() {
  cin >> n;
  a = vector<int>(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> l;
  vector<vector<int> > dp(18, vector<int>(n));
  for (int i = 0; i < 18; i++)
    for (int j = n - 1; j >= 0; j--) {
      if (!i)
        dp[i][j] = upper_bound(a.begin(), a.end(), a[j] + l) - a.begin() - 1;
      else
        dp[i][j] = dp[i - 1][dp[i - 1][j]];
    }
  vector<int> num(18);
  num[0] = 1;
  for (int i = 1; i < 18; i++) num[i] = num[i - 1] * 2;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    if (A > B) swap(A, B);
    int ans = 0, now = A;
    while (1) {
      bool flag = 1;
      for (int i = 17; i >= 0; i--)
        if (dp[i][now] < B) {
          ans += num[i];
          now = dp[now][i];
          flag = 0;
          break;
        }
      if (flag) break;
    }
    cout << ans + 1 << endl;
  }
}
