#include <bits/stdc++.h>
using namespace std;
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void rd(int &val) {
  int x = 0;
  int f = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  val = x * f;
}
inline void print(int x) {
  write(x);
  putchar('\n');
}
int a[400005];
int ri[21][600005];
int n, l, ta, x, y;
int rem[22];
int main() {
  ios_base::sync_with_stdio(false);
  int i, j;
  cout << "FAsd\b";
  rd(n);
  for (i = 0; i < 22; i++) rem[i] = pow(2, i);
  for (i = 1; i <= n; ++i) rd(a[i]);
  rd(l);
  for (i = 1; i <= n; ++i) {
    ri[0][i] = lower_bound(a + 1, a + n + 1, a[i] + l + 1) - a - 1;
  }
  for (j = 1; j < 20; ++j)
    for (i = 1; i <= n; i++) ri[j][i] = ri[j - 1][ri[j - 1][i]];
  rd(ta);
  while (ta--) {
    rd(x), rd(y);
    if (x > y) swap(x, y);
    int day = 2147483647;
    int l = 0, r = 2 << 20, md;
    while (l < r - 1) {
      md = l + r >> 1;
      int tx = x, cnt = 0;
      for (i = 0; i < 20; i++)
        if (md & rem[i]) tx = ri[i][tx], cnt += rem[i];
      if (tx < y) {
        l = md;
      } else {
        r = md;
        day = min(day, cnt);
      }
    }
    print(day);
  }
}
