#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int MAX_N = 1e5 + 1;
int N, L, Q;
int x[MAX_N];
vector<int> v[MAX_N];
void solv(int a) {
  int* pos = upper_bound(x, x + MAX_N, x[a] + L);
  int po = (int)(pos - x) - 1;
  v[a].push_back(po);
  int i = 0;
  while (v[po].size() > i) {
    v[a].push_back(v[po][i]);
    po = v[po][i];
    i++;
  }
}
int query(int a, int b) {
  int res = 0;
  while (a < b) {
    vector<int>::iterator it1 = lower_bound(v[a].begin(), v[a].end(), b);
    int z = (int)(it1 - v[a].begin());
    a = *it1;
    res += 1 << z;
  }
  return res;
}
int main() {
  fill(x, x + MAX_N, INF);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  cin >> L;
  for (int i = N - 2; i >= 0; i--) {
    solv(i);
  }
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) {
      swap(a, b);
    }
    int res = query(a, b);
    cout << res << endl;
  }
  return 0;
}
