#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = acos(-1);
const int INF = 1e9;
const long long MOD = 1e9 + 7;
long long addMod(long long a, long long b) { return (a + b) % MOD; }
long long mulMod(long long a, long long b) { return (a * b) % MOD; }
const int N = 1e5;
int len, n;
set<pair<int, int> > lst;
set<int> updated;
int x[N + 5];
int step[N + 5];
void getNext() {
  set<pair<int, int> >::iterator it;
  set<int>::iterator it2;
  for (int i = 1; i <= n; i += 1) {
    if (step[i] == -1) {
      it2 = updated.lower_bound(i);
      it2--;
      step[i] = step[(*it2)];
    }
    it = lst.lower_bound(make_pair(x[i] + len + 1, 0));
    it--;
    int nxt = (*it).second;
    if (nxt != i && step[nxt] == -1) {
      step[nxt] = step[i] + 1;
      updated.insert(nxt);
    }
  }
}
int solve(int st, int en) {
  if (step[st] > step[en]) return 1;
  return step[en] - step[st] + 1;
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(step, -1, sizeof step);
  cin >> n;
  for (int i = 1; i <= n; i += 1) {
    cin >> x[i];
    lst.insert(make_pair(x[i], i));
  }
  x[n + 1] = 2 * INF + 5;
  lst.insert(make_pair(x[n + 1], n + 1));
  step[1] = 0;
  updated.insert(1);
  updated.insert(n + 1);
  cin >> len;
  getNext();
  int q, st, en;
  cin >> q;
  for (int i = 0; i <= (int)q - 1; i += 1) {
    cin >> st >> en;
    if (x[st] > x[en]) swap(st, en);
    cout << solve(st, en) << endl;
  }
  return 0;
}
