#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
namespace finp {
char buf[100005], *p0 = buf + 100000, *p1 = buf + 100000;
char rchar() {
  if (p0 == p1) fread(p0 = buf, 1, 100000, stdin);
  return *(p0++);
}
int getint() {
  int ret = 0;
  char ch = rchar();
  while (ch == ' ' || ch == '\n') ch = rchar();
  do {
    ret = ret * 10 + ch - '0';
    ch = rchar();
  } while (ch != ' ' && ch != '\n');
  return ret;
}
}  // namespace finp
namespace foutp {
char buf[100005], *p0 = buf, *p1 = buf + 100000;
void pchar(char ch) {
  if (ch == EOF) {
    fwrite(buf, 1, p0 - buf, stdout);
    return;
  }
  if (p0 == p1) fwrite(p0 = buf, 1, 100000, stdout);
  *(p0++) = ch;
}
char ib[100005];
void putint(int x) {
  int cur = 0;
  do {
    ib[cur++] = x % 10 + '0';
    x /= 10;
  } while (x > 0);
  reverse(ib, ib + cur);
  for (int i = 0; i < (int)(cur); i++) pchar(ib[i]);
}
}  // namespace foutp
using finp::getint;
using finp::rchar;
using foutp::pchar;
using foutp::putint;
int pos[100005];
int par[100005];
int nxe[100005], eto[100005], hd[100005], ecnt;
int dfn[100005], dep[100005], tot;
inline void pb(int u, int v) {
  nxe[ecnt] = hd[u];
  eto[ecnt] = v;
  hd[u] = ecnt++;
}
void dfs(int v, int cd) {
  dep[v] = cd;
  dfn[v] = tot++;
  for (int i = hd[v]; i != -1; i = nxe[i]) dfs(eto[i], cd + 1);
}
int main() {
  int n, l, q;
  n = getint();
  for (int i = 0; i < (int)(n); i++) pos[i] = getint();
  l = getint();
  q = getint();
  int rp = 0;
  for (int i = 0; i < (int)(n - 1); i++) {
    while (rp < n && pos[rp] - pos[i] <= l) rp++;
    par[i] = rp - 1;
  }
  memset(hd, -1, sizeof(hd));
  for (int i = 0; i < (int)(n - 1); i++) pb(par[i], i);
  dfs(n - 1, 0);
  for (int i = 0; i < (int)(q); i++) {
    int a, b;
    a = getint();
    b = getint();
    a--;
    b--;
    if (a > b) swap(a, b);
    int ans = dep[a] - dep[b];
    if (dfn[a] < dfn[b]) ans++;
    putint(ans);
    pchar('\n');
  }
  pchar(EOF);
  return 0;
}
