#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int n;
  scanf("%d", &n);
  std::vector<int> x(n);
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  int l;
  scanf("%d", &l);
  int q;
  scanf("%d", &q);
  std::vector<std::vector<int> > d(20, std::vector<int>(n));
  for (int i = 0; i < n; i++) {
    d[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++) {
      d[k][i] = d[k - 1][d[k - 1][i]];
    }
  }
  std::vector<int> d2(1, 1);
  for (int i = 0; i < 20; i++) d2.push_back(d2.back() * 2);
  for (int i = 0; i < q; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a > b) swap(a, b);
    a--;
    b--;
    int ans = 0;
    int cur = 19;
    while (a < b) {
      if (d[cur][a] <= b) {
        a = d[cur][a];
        ans += d2[cur];
      }
      cur--;
    }
    printf("%d\n", ans);
  }
}
