#include <bits/stdc++.h>
using namespace std;
int dp[100050][18];
vector<int> hotels;
int l;
int n;
int beki[30];
int f(int a, int b) {
  if (dp[a][1] >= b) {
    return 1;
  }
  for (int day = 0; day <= 17; day++) {
    if (dp[a][day] >= b) {
      return beki[day - 2] + f(dp[a][day - 1], b);
    }
  }
}
int main() {
  beki[0] = 1;
  for (int i = 1; i <= 25; i++) {
    beki[i] = beki[i - 1] * 2;
  }
  hotels.push_back(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int in;
    cin >> in;
    hotels.push_back(in);
  }
  cin >> l;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = i;
    dp[i][1] =
        distance(hotels.begin(),
                 upper_bound(hotels.begin(), hotels.end(), hotels[i] + l)) -
        1;
  }
  for (int day = 2; day <= 17; day++) {
    dp[n][day] = n;
    for (int pos = 1; pos <= n - 1; pos++) {
      dp[pos][day] = dp[dp[pos][day - 1]][day - 1];
    }
  }
  int q;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    int a, b;
    cin >> a >> b;
    if (a > b) {
      swap(a, b);
    }
    cout << f(a, b) << endl;
  }
  return 0;
}
