#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
const long long ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;
int x[101010];
int main() {
  int n, l, q;
  cin >> n;
  fill(x, x + 101010, inf);
  for (int i = (0); i < (n); i++) cin >> x[i];
  cin >> l >> q;
  for (int i = (0); i < (q); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    int cnt = 0;
    a = x[a];
    b = x[b];
    if (a < b)
      while (a < b) {
        cnt++;
        int *p = upper_bound(x, x + n, a + l);
        if (*p == x[n]) break;
        p--;
        a = *p;
      }
    else if (a > b)
      while (a > b) {
        cnt++;
        int *p = lower_bound(x, x + n, a - l);
        if (*p == x[0]) break;
        a = *p;
      }
    cout << cnt << endl;
  }
  return 0;
}
