#include <bits/stdc++.h>
using namespace std;
namespace IO {
const unsigned int Buffsize = 1 << 15, Output = 1 << 23;
static char Ch[Buffsize], *S = Ch, *T = Ch;
inline char getc() {
  return ((S == T) && (T = (S = Ch) + fread(Ch, 1, Buffsize, stdin), S == T)
              ? 0
              : *S++);
}
static char Out[Output], *nowps = Out;
inline void flush() {
  fwrite(Out, 1, nowps - Out, stdout);
  nowps = Out;
}
template <typename T>
inline void read(T& x) {
  x = 0;
  static char ch;
  T f = 1;
  for (ch = getc(); !isdigit(ch); ch = getc())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getc()) x = x * 10 + (ch ^ 48);
  x *= f;
}
template <typename T>
inline void write(T x, char ch = '\n') {
  if (!x) *nowps++ = '0';
  if (x < 0) *nowps++ = '-', x = -x;
  static unsigned int sta[111], tp;
  for (tp = 0; x; x /= 10) sta[++tp] = x % 10;
  for (; tp; *nowps++ = sta[tp--] ^ 48)
    ;
  *nowps++ = ch;
}
}  // namespace IO
using namespace IO;
inline void file() {}
const int MAXN = 1e5 + 7;
static int n, l, q;
static int x[MAXN];
inline void init() {
  read(n);
  for (register int i = (1); i <= (n); ++i) read(x[i]);
  read(l);
  read(q);
}
static int nxt[19][MAXN], pr[19][MAXN];
inline void solve() {
  for (register int i = (1); i <= (n); ++i) {
    nxt[0][i] = upper_bound(x + 1, x + n + 1, x[i] + l) - x - 1;
    pr[0][i] = lower_bound(x + 1, x + n + 1, x[i] - l) - x;
  }
  for (register int i = (0); i <= (17); ++i) nxt[i][n + 1] = n + 1;
  for (register int i = (0); i <= (17); ++i) pr[i][0] = 0;
  for (register int j = (1); j <= (17); ++j)
    for (register int i = (1); i <= (n); ++i)
      nxt[j][i] = nxt[j - 1][nxt[j - 1][i]], pr[j][i] = pr[j - 1][pr[j - 1][i]];
  x[0] = 0;
  x[n + 1] = INT_MAX;
  static int st, ed, ans;
  for (register int i = (1); i <= (q); ++i) {
    read(st), read(ed);
    ans = 0;
    if (st < ed) {
      for (register int i = (17); i >= (0); --i)
        if (nxt[i][st] <= ed) ans |= 1 << i, st = nxt[i][st];
      write(ans + (st != ed));
    } else {
      for (register int i = (17); i >= (0); --i)
        if (pr[i][st] >= ed) ans |= 1 << i, st = pr[i][st];
      write(ans + (st != ed));
    }
  }
  flush();
}
int main() {
  init();
  solve();
  return 0;
}
