#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
using P = pair<long long, long long>;
template <typename T>
void chmin(T &a, T b) {
  if (a > b) a = b;
}
template <typename T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
void pmod(long long &a, long long b) { a = (a + b) % MOD; }
void pmod(long long &a, long long b, long long c) { a = (b + c) % MOD; }
void qmod(long long &a, long long b) { a = (a * b) % MOD; }
void qmod(long long &a, long long b, long long c) { a = (b * c) % MOD; }
long long median(long long a, long long b, long long c) {
  return a + b + c - max({a, b, c}) - min({a, b, c});
}
void ans1(bool x) {
  if (x)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
void ans2(bool x) {
  if (x)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
void ans3(bool x) {
  if (x)
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;
}
template <typename T1, typename T2>
void ans(bool x, T1 y, T2 z) {
  if (x)
    cout << y << endl;
  else
    cout << z << endl;
}
template <typename T>
void debug(vector<vector<T>> v, long long h, long long w) {
  for (long long i = 0; i < h; i++) {
    cout << v[i][0];
    for (long long j = 1; j < w; j++) cout << " " << v[i][j];
    cout << endl;
  }
};
void debug(vector<string> v, long long h, long long w) {
  for (long long i = 0; i < h; i++) {
    for (long long j = 0; j < w; j++) cout << v[i][j];
    cout << endl;
  }
};
template <typename T>
void debug(vector<T> v, long long n) {
  cout << v[0];
  for (long long i = 1; i < n; i++) cout << " " << v[i];
  cout << endl;
};
template <typename T>
vector<vector<T>> vec(long long x, long long y, T w) {
  vector<vector<T>> v(x, vector<T>(y, w));
  return v;
}
long long gcd(long long x, long long y) {
  long long r;
  while (y != 0 && (r = x % y) != 0) {
    x = y;
    y = r;
  }
  return y == 0 ? x : y;
}
template <typename T>
void emp(map<T, long long> &m, T x) {
  m.emplace(x, 0).first->second++;
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  long long res = 0, res1 = INF, res2 = -INF, buf = 0;
  bool judge = true;
  long long n;
  cin >> n;
  vector<long long> x(n);
  vector<long long> tw(32, 1);
  for (long long i = 1; i < (long long)(32); i++) {
    tw[i] = tw[i - 1] * 2;
  }
  for (long long i = 0; i < (long long)(n); i++) cin >> x[i];
  long long l, q;
  cin >> l >> q;
  vector<long long> a(q), b(q);
  for (long long i = 0; i < (long long)(q); i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  auto next = vec(n, 32, 0LL);
  auto prev = vec(n, 32, 0LL);
  for (long long i = 0; i < (long long)(n); i++) {
    next[i][0] = upper_bound((x).begin(), (x).end(), x[i] + l) - x.begin() - 1;
    prev[i][0] = lower_bound((x).begin(), (x).end(), x[i] - l) - x.begin();
  }
  for (long long i = 1; i < (long long)(32); i++) {
    for (long long j = 0; j < (long long)(n); j++) {
      next[j][i] = next[next[j][i - 1]][i - 1];
      prev[j][i] = prev[prev[j][i - 1]][i - 1];
    }
  }
  for (long long i = 0; i < (long long)(q); i++) {
    long long x = a[i];
    long long ret = 0;
    if (a[i] < b[i]) {
      while (x < b[i]) {
        long long cnt = 0;
        cnt = upper_bound((next[x]).begin(), (next[x]).end(), b[i]) -
              next[x].begin() - 1;
        ret += tw[cnt];
        x = next[x][cnt];
      }
    } else {
      while (x > b[i]) {
        long long cnt = 0;
        while (prev[x][cnt] > b[i]) cnt++;
        if (cnt > 0 && prev[x][cnt] != b[i]) cnt--;
        ret += tw[cnt];
        x = prev[x][cnt];
      }
    }
    cout << ret << endl;
  }
  return 0;
}
