#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("sse3", "sse2", "sse")
#pragma GCC target("avx", "sse4", "sse4.1", "sse4.2", "ssse3")
#pragma GCC target("f16c")
#pragma GCC optimize("inline", "fast-math", "unroll-loops", \
                     "no-stack-protector")
using namespace std;
const int block_size = 320;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 7;
const long double eps = 1e-9;
const double PI = atan(1) * 4;
template <typename T>
inline int sign(const T &a) {
  if (a < 0) return -1;
  if (a > 0) return 1;
  return 0;
}
template <typename T, typename S>
inline bool upmin(T &a, const S &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T, typename S>
inline bool upmax(T &a, const S &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline void in(T &x) {
  x = 0;
  T f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
long long twop(int x) { return 1LL << x; }
template <typename A, typename B>
inline void in(A &x, B &y) {
  in(x);
  in(y);
}
template <typename A, typename B, typename C>
inline void in(A &x, B &y, C &z) {
  in(x);
  in(y);
  in(z);
}
template <typename A, typename B, typename C, typename D>
inline void in(A &x, B &y, C &z, D &d) {
  in(x);
  in(y);
  in(z);
  in(d);
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
namespace SOLVE {
void main() {}
}  // namespace SOLVE
const int maxn = 100010;
long long n, l, q, x[maxn], fa[maxn], jump[maxn];
void init() {
  queue<long long> q;
  for (long long i = 1; i < n + 1; i++) fa[i] = n;
  for (long long i = 1; i < n + 1; i++) {
    while (((int)q.size()) && x[i] - x[q.front()] > l) {
      fa[q.front()] = i - 1;
      q.pop();
    }
    q.push(i);
  }
  for (long long i = 1; i < n + 1; i++) {
    int cur = i;
    for (long long j = 0; j < block_size; j++) {
      cur = fa[cur];
    }
    jump[i] = cur;
  }
}
int main() {
  in(n);
  for (long long i = 1; i < n + 1; i++) in(x[i]);
  in(l, q);
  init();
  for (long long i = 0; i < q; i++) {
    int l, r;
    in(l, r);
    int ans = 0;
    while (jump[l] < r) {
      l = jump[l];
      ans += block_size;
    }
    while (l < r) {
      ans++;
      l = fa[l];
    }
    cout << ans;
  }
  return 0;
}
