#include <bits/stdc++.h>
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6;
const long long LINF = 1e18;
using namespace std;
long long n, cnt, ans, a, b, c, d, tmp, tmpp, m, h, w, x[ohara], y, sum, pos, k,
    q, l, r[35][ohara];
long double doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl;
struct edge {
  int to, cost;
};
unordered_map<long long, long long> mp;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  set<long long> st;
  for (int(i) = 0; (i) < (int)(n); (i)++)
    cin >> x[i], st.insert(x[i]), mp[x[i]] = i;
  cin >> l >> q;
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    auto iti = st.upper_bound(x[i] + l);
    iti--;
    pos = *iti;
    pos = mp[pos];
    r[0][i] = pos;
  }
  for (int i = (1); i < (31); i++) {
    for (int(j) = 0; (j) < (int)(n); (j)++) {
      r[i][j] = r[i - 1][r[i - 1][j]];
    }
  }
  for (int(i) = 0; (i) < (int)(q); (i)++) {
    long long fr, to, now;
    cin >> fr >> to;
    fr--;
    to--;
    if (fr > to) {
      tmp = fr;
      fr = to;
      to = tmp;
    }
    now = fr;
    for (int j = (30); j >= (0); j--) {
      if (r[j][now] <= to) {
        now = r[j][now];
        ans += 1 << j;
        if (now == to) break;
      }
    }
    cout << (ans) << endl;
    ans = 0;
  }
  return 0;
}
