#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long int linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int N[30][100001];
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<long long int> x(n);
  for (int i = (0); i < (n); ++i) cin >> x[i];
  long long int l;
  int q;
  cin >> l >> q;
  for (int i = (0); i < (n); ++i) {
    N[0][i] = upper_bound((x).begin(), (x).end(), x[i] + l) - x.begin() - 1;
  }
  for (int k = (1); k < (20); ++k) {
    for (int i = (0); i < (n); ++i) {
      N[k][i] = N[k - 1][N[k - 1][i]];
    }
  }
  for (int i_ = (0); i_ < (q); ++i_) {
    int a, b;
    cin >> a >> b, a--, b--;
    if (a > b) swap(a, b);
    int res = 0;
    int at = a;
    while (true) {
      int k = 0;
      while (N[k][at] < b) {
        k++;
      }
      if (N[k][at] == b || k == 0) {
        cout << res + (1 << k) << endl;
        break;
      }
      k--;
      res += 1 << k;
      at = N[k][at];
    }
  }
  return 0;
}
