#include <bits/stdc++.h>
using namespace std;
struct pairhash {
 public:
  template <typename T, typename U>
  size_t operator()(const pair<T, U> &x) const {
    size_t seed = hash<T>()(x.first);
    return hash<U>()(x.second) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
  }
};
const int inf = 1e9 + 9;
const long long mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);
int n;
int x[100100];
int l, q;
int a[100100], b[100100];
int d[100100][20];
int calc(int idx0, int idx1) {
  int t = idx0;
  int res = 0;
  while (t < idx1) {
    int s = 19;
    while (d[t][s] > idx1) s--;
    t = d[t][s];
    res += (1 << s);
  }
  return res;
}
int calc0(int k) {
  int lb = k, ub = n + 1;
  while (ub - lb > 1) {
    int mid = (ub + lb) / 2;
    if (x[mid] - x[k] <= l) {
      lb = mid;
    } else {
      ub = mid;
    }
  }
  return lb;
}
void solve() {
  for (int i = 0; i <= n; i++) {
    d[i][0] = calc0(i);
  }
  for (int i = 1; i < 20; i++) {
    for (int j = 0; j <= n; j++) {
      d[j][i] = d[d[j][i - 1]][i - 1];
    }
  }
  for (int i = 0; i < q; i++) {
    if (a[i] > b[i]) swap(a[i], b[i]);
    cout << calc(a[i], b[i]) << '\n';
  }
}
void input() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i];
  x[n] = x[n - 1] + 1;
  cin >> l >> q;
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  input();
  solve();
}
