#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
const long long LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
template <typename T>
T gcd(T a, T b) {
  return (a == 0) ? b : gcd(b % a, a);
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
bool p_comp_fs(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.first < p2.first;
};
bool p_comp_fg(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.first > p2.first;
};
bool p_comp_ss(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.second < p2.second;
};
bool p_comp_sg(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.second > p2.second;
};
template <typename T>
vector<T> uniquen(vector<T> vec) {
  sort((vec).begin(), (vec).end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;
}
inline long long popcnt(long long x) {
  return __builtin_popcountll((unsigned long long)x);
};
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long N;
  cin >> N;
  vector<long long> X(N);
  for (long long i = 0; i < N; i++) cin >> X[i];
  long long L, Q;
  cin >> L >> Q;
  vector<vector<long long> > label(N);
  vector<long long> inv_lable(N);
  set<long long> outstand;
  for (long long i = 0; i < N; i++) outstand.insert(X[i]);
  long long k = 0;
  while (!outstand.empty()) {
    long long now = *outstand.begin();
    long long idx = lower_bound((X).begin(), (X).end(), now) - X.begin();
    while (idx < N && !outstand.empty()) {
      if (outstand.count(now) == 0) break;
      outstand.erase(outstand.lower_bound(now));
      label[k].push_back(idx);
      inv_lable[idx] = k;
      auto nit = --upper_bound((X).begin(), (X).end(), now + L);
      idx = nit - X.begin();
      now = *nit;
    }
    k++;
  }
  for (long long _ = 0; _ < Q; _++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    long long label_a = inv_lable[a];
    auto toit =
        lower_bound((label[label_a]).begin(), (label[label_a]).end(), b);
    if (toit != label[label_a].end()) {
      auto bit =
          lower_bound((label[label_a]).begin(), (label[label_a]).end(), a);
      cout << toit - bit << endstr;
    } else {
      long long res =
          toit -
          lower_bound((label[label_a]).begin(), (label[label_a]).end(), a) - 1;
      long long e =
          --upper_bound((X).begin(), (X).end(), X[*prev(toit)] + L) - X.begin();
      auto nit = lower_bound((label[0]).begin(), (label[0]).end(), e);
      auto eit = lower_bound((label[0]).begin(), (label[0]).end(), b);
      cout << res + (eit - nit) + 1 << endstr;
    }
  }
  return 0;
}
