#include <bits/stdc++.h>
using namespace std;
struct data {
  int first, second, id;
  data(int _f, int _s, int _id) : first(_f), second(_s), id(_id) {}
};
const int N = (int)1e5 + 5;
int n, m, len, a[N], dp[17][N];
int query(int u, int steps) {
  int ret = u;
  for (int i = 0; i < 20; ++i)
    if ((steps >> i) & 1) ret = dp[i][ret];
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  scanf("%d%d", &len, &m);
  for (int i = n, j = n; i >= 1; --i) {
    while (j >= 1 && a[j] - a[i] > len) --j;
    dp[0][i] = j;
  }
  for (int i = 1; i <= 16; ++i)
    for (int j = 1; j <= n; ++j) dp[i][j] = dp[i - 1][dp[i - 1][j]];
  for (int i = 1, u, v; i <= m; ++i) {
    scanf("%d%d", &u, &v);
    if (u > v) swap(u, v);
    int lo = 1, hi = n, ans = -1, mid;
    while (lo <= hi) {
      mid = (lo + hi) >> 1;
      if (query(u, mid) >= v)
        ans = mid, hi = mid - 1;
      else
        lo = mid + 1;
    }
    printf("%d\n", ans);
  }
  return 0;
}
