#include <bits/stdc++.h>
using namespace std;
template <class T>
void debug(T itr1, T itr2) {
  auto now = itr1;
  while (now < itr2) {
    cout << *now << " ";
    now++;
  }
  cout << endl;
}
const long long MOD = pow(10, 9) + 7;
const long long LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;
vector<long long> fac;
void c_fac(int x = pow(10, 6) + 10) {
  fac.resize(x, true);
  for (int i = (int)0; i < (int)x; i++) fac[i] = i ? (fac[i - 1] * i) % MOD : 1;
}
long long inv(long long a, long long m = MOD) {
  long long b = m, x = 1, y = 0;
  while (b != 0) {
    int d = a / b;
    a -= b * d;
    swap(a, b);
    x -= y * d;
    swap(x, y);
  }
  return (x + m) % m;
}
long long nck(long long n, long long k) {
  return fac[n] * inv(fac[k] * fac[n - k] % MOD) % MOD;
}
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  return b == 0 ? a : gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int ln2 = 0;
vector<vector<int>> adj;
vector<vector<long long>> par;
vector<long long> rnk;
void calc_parent(int n) {
  for (int i = (int)0; i < (int)ln2; i++)
    for (int j = (int)0; j < (int)n; j++)
      if (rnk[j] >= powl(2, i + 1)) par[j][i + 1] = par[par[j][i]][i];
}
void calc_rnk(int n = 0, int p = -1) {
  if (p == -1) rnk[n] = 0;
  for (auto x : adj[n]) {
    if (x != p) {
      rnk[x] = rnk[n] + 1;
      par[x][0] = n;
      calc_rnk(x, n);
    }
  }
}
void init_lca() {
  int n = adj.size();
  while (n >= (1 << ln2)) ln2++;
  par.resize(n, vector<long long>(ln2, -1));
  rnk.resize(n);
  calc_rnk();
  calc_parent(n);
}
bool large(int u, int v) {
  if (rnk[u] < rnk[v]) swap(u, v);
  int diff = rnk[u] - rnk[v];
  int b_pos = 0;
  while (diff >= (1ull << b_pos)) {
    if (diff & (1ull << b_pos)) u = par[u][b_pos];
    b_pos++;
  }
  return u > v;
}
int main() {
  int N;
  cin >> N;
  long long x[N];
  for (int i = (int)0; i < (int)N; i++) cin >> x[i];
  long long L;
  cin >> L;
  adj.resize(N);
  for (int i = (int)1; i < (int)N; i++) {
    auto par = lower_bound(x, x + N, x[i] - L);
    adj[par - x].push_back(i);
  }
  init_lca();
  debug(rnk.begin(), rnk.end());
  int Q;
  cin >> Q;
  for (int i = (int)0; i < (int)Q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a < b) swap(a, b);
    int result = large(a, b) ? rnk[a] - rnk[b] + 1 : rnk[a] - rnk[b];
    cout << result << endl;
  }
  return 0;
}
