#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
constexpr double EPS = 1e-9;
constexpr double PI = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL << 60;
constexpr long long MOD = 1000000007;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int N, L, LOGN;
vector<int> x;
vector<vector<int>> tab, tab2;
void doubling() {
  for (int i = 0; i < N; i++) {
    int it = upper_bound((x).begin(), (x).end(), x[i] + L) - (x).begin();
    if (it - 1 == i)
      tab[i][0] = -1;
    else
      tab[i][0] = it - 1;
  }
  for (int k = 0; k < LOGN; k++)
    for (int i = 0; i < N; i++) {
      if (tab[i][k] == -1)
        tab[i][k + 1] = -1;
      else
        tab[i][k + 1] = tab[tab[i][k]][k];
    }
}
int query(int n, long long k) {
  int ret = n, count = 0;
  while (k) {
    if (k & 1) ret = tab[ret][count];
    count++;
    k >>= 1;
    if (ret == -1) return ret;
  }
  return ret;
}
void doubling2() {
  for (int i = 0; i < N; i++) {
    int it = lower_bound((x).begin(), (x).end(), x[i] - L) - (x).begin();
    if (it == i)
      tab2[i][0] = -1;
    else
      tab2[i][0] = it;
  }
  for (int k = 0; k < LOGN; k++)
    for (int i = 0; i < N; i++) {
      if (tab2[i][k] == -1)
        tab2[i][k + 1] = -1;
      else
        tab2[i][k + 1] = tab2[tab2[i][k]][k];
    }
}
int query2(int n, long long k) {
  int ret = n, count = 0;
  while (k) {
    if (k & 1) ret = tab2[ret][count];
    count++;
    k >>= 1;
    if (ret == -1) return ret;
  }
  return ret;
}
void Main() {
  cin >> N;
  LOGN = floor(log2(N)) + 1;
  x.resize(N);
  tab.resize(N, vector<int>(LOGN + 1)), tab2.resize(N, vector<int>(LOGN + 1));
  for (int i = (0); i < (N); ++i) cin >> x[i];
  cin >> L;
  doubling();
  doubling2();
  int Q;
  cin >> Q;
  for (int _ = (0); _ < (Q); ++_) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    int ans;
    if (a < b) {
      int l = 0, r = N;
      while (r - l > 1) {
        int k = (l + r) / 2;
        int loc = query(a, k);
        if (loc < b && loc != -1)
          l = k;
        else
          r = k;
      }
      ans = r;
    } else {
      int l = 1, r = N;
      while (r - l > 1) {
        int k = (l + r) / 2;
        int loc = query2(a, k);
        if (b < loc && loc != -1)
          l = k;
        else
          r = k;
      }
      ans = r;
    }
    cout << ans << "\n";
  }
  return;
}
int main(void) {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(15);
  int t = 1;
  for (int _ = (0); _ < (t); ++_) Main();
  return 0;
}
