#include <bits/stdc++.h>
using namespace std;
template <typename T = long long>
inline T IN() {
  T x;
  cin >> x;
  return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&...tail) {
  cin >> head;
  CIN(move(tail)...);
}
template <typename T = string>
inline void eputs(T s) {
  cout << s << "\n";
  exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
}
template <typename T>
using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using PQ = priority_queue<T>;
const long long INF = 1e9;
const long long MOD = 1e9 + 7;
const long long LINF = 1e18;
const long long dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
signed main() {
  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);
  long long dep = log2(N);
  vector<vector<long long>> table(N, vector<long long>(dep + 1));
  for (long long i = 0; i < (N); ++i) {
    long long lb = i, ub = N;
    while (ub - lb > 1) {
      long long mid = (ub + lb) / 2;
      if (x[mid] - x[i] <= L)
        lb = mid;
      else
        ub = mid;
    }
    table[i][0] = lb;
  }
  for (long long d = 0; d < (dep); ++d)
    for (long long i = 0; i < (N); ++i) {
      if (table[i][d] == N) {
        table[i][d + 1] = N;
      } else {
        table[i][d + 1] = table[table[i][d]][d];
      }
    }
  for (long long i = 0; i < (Q); ++i) {
    long long a, b;
    CIN(a, b);
    a--, b--;
    if (a > b) swap(a, b);
    long long now = a, cnt = 0;
    while (now < b) {
      long long idx = upper_bound((table[now]).begin(), (table[now]).end(), b) -
                      table[now].begin();
      idx = max(0LL, idx - 1);
      now = table[now][idx];
      cnt += pow(2, idx);
    }
    cout << cnt << "\n";
  }
}
