#include <bits/stdc++.h>
using namespace std;
struct I {
  I() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} init;
const long long MOD = 1e9 + 7;
const long long INF = 1e16;
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& it : v) is >> it;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (int i = 0, sz = v.size(); i < sz; i++) os << (!i) + " " << v[i];
  return os;
}
int AB[100000][32];
int BA[100000][32];
void calc(vector<long long>& x, long long L) {
  int N = x.size();
  for (int i = 0; i < N; i++) {
    int can = i, cannot = N;
    while (abs(cannot - can) > 1) {
      const int mid = (can + cannot) / 2;
      if (abs(x[mid] - x[i]) <= L)
        can = mid;
      else
        cannot = mid;
    }
    AB[i][0] = can;
  }
  for (int i = 0; i < N; i++) {
    int can = i, cannot = -1;
    while (abs(cannot - can) > 1) {
      const int mid = (can + cannot) / 2;
      if (abs(x[mid] - x[i]) <= L)
        can = mid;
      else
        cannot = mid;
    }
    BA[i][0] = can;
  }
  for (int k = 1; k < 30; k++)
    for (int i = 0; i < N; i++) {
      AB[i][k] = AB[AB[i][k - 1]][k - 1];
      BA[i][k] = BA[BA[i][k - 1]][k - 1];
    }
}
int main() {
  int N, Q;
  long long L;
  cin >> N;
  vector<long long> x(N);
  cin >> x;
  cin >> L >> Q;
  calc(x, L);
  vector<int> a(Q), b(Q);
  for (int i = 0; i < Q; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  for (int i = 0; i < Q; i++) {
    long long res = 0;
    int now = a[i];
    if (a[i] < b[i]) {
      int k = 25;
      while (now < b[i]) {
        while (k > 0 && AB[now][k - 1] >= b[i]) k--;
        res += (1 << k);
        now = AB[now][k];
      }
      cout << res << endl;
    } else {
      int k = 25;
      while (now > b[i]) {
        while (k > 0 && BA[now][k - 1] <= b[i]) k--;
        res += (1 << k);
        now = BA[now][k];
      }
      cout << res << endl;
    }
  }
  return 0;
}
