#include <bits/stdc++.h>
using namespace std;
int n;
int x[111111];
int l, q;
int a[111111];
int b[111111];
int e[111111][33];
int main(void) {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  x[n] = 1111111111;
  cin >> l >> q;
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    if (a[i] > b[i]) swap(a[i], b[i]);
  }
  for (int i = 0; i < n; i++) {
    e[i][0] = i;
    e[i][1] = (upper_bound(x, x + n + 1, x[i] + l) - x - 1);
  }
  for (int k = 2; k < 33; k++) {
    for (int i = 0; i < n; i++) {
      e[i][k] = e[e[i][k - 1]][k - 1];
    }
  }
  for (int i = 0; i < q; i++) {
    int ans = 0;
    int np = a[i];
    while (1) {
      int *p = (upper_bound(e[np], e[np] + 33, b[i]) - 1);
      ans += 1 << (p - e[np] - 1);
      if (b[i] == *p) break;
      np = *p;
      cout << ans << endl;
    }
    cout << ans << endl;
  }
}
