#include <bits/stdc++.h>
using namespace std;
const long long MAX = 200000;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double PI = 3.1415926535897932;
long long N, L, Q, ans = 0, tmp = 0;
vector<long long> A, C;
vector<vector<long long>> G;
string S;
signed main() {
  cin >> N;
  for (long long i = 0; i < N; i++) {
    long long a;
    cin >> a;
    A.push_back(a);
    if (i == 0)
      C.push_back(0);
    else
      C.push_back(INF);
  }
  cin >> L >> Q;
  for (long long i = 1; i < N; i++) {
    long long id = lower_bound(A.begin(), A.end(), A[i] - L) - A.begin();
    C[i] = C[id] + 1;
  }
  for (long long i = 0; i < Q; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    cout << max(1LL, abs(C[a] - C[b])) << endl;
  }
  return 0;
}
