#include <bits/stdc++.h>
const double PI = 3.1415926535897932384626433832795028841971;
const int INF = 100000000;
const double EPS = 1e-10;
const int MOD = 1000000007;
using namespace std;
int n, l, q;
long long x[100000];
long long to[100000][31];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%lld", x + i);
  }
  cin >> l;
  for (int i = 0; i < n; i++) {
    int s = i, e = n, mid;
    while (e - s > 1) {
      mid = (s + e) / 2;
      if (x[mid] - x[i] <= l)
        s = mid;
      else
        e = mid;
    }
    to[i][0] = s;
  }
  for (int i = 1; i < 31; i++) {
    for (int j = 0; j < n; j++) {
      to[j][i] = to[to[j][i - 1]][i - 1];
    }
  }
  cin >> q;
  while (q--) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    if (b < a) swap(a, b);
    long long ans = 0;
    while (true) {
      bool end = false;
      for (int i = 30; i >= 0; i--) {
        if (to[a][i] == b) {
          ans += (1 << i);
          end = true;
          break;
        }
        if (to[a][i] > b && i == 0) {
          ans += 1;
          end = true;
          break;
        }
        if (to[a][i] < b) {
          ans += (1 << i);
          a = to[a][i];
          break;
        }
      }
      if (end) break;
    }
    printf("%lld\n", ans);
  }
}
