#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& s) {
  s = 0;
  int f = 0;
  char c = getchar();
  while (!isdigit(c)) f |= (c == '-'), c = getchar();
  while (isdigit(c)) s = s * 10 + (c ^ 48), c = getchar();
  s = f ? -s : s;
}
const int _ = 100010;
int n, L, q, x[_], to[_];
inline int solve(int a, int b) {
  if (a > b) swap(a, b);
  int res = 0;
  for (register int i = a; i != b; i = to[i]) ++res;
  return res;
}
int main() {
  read(n);
  for (register int i = 1; i <= n; ++i) read(x[i]);
  read(L), read(q);
  for (register int i = 1; i <= n; ++i) {
    int l = i, r = n, ans;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (x[mid] - x[i] <= L)
        ans = mid, l = mid + 1;
      else
        r = mid - 1;
    }
    to[i] = ans;
  }
  for (register int a, b, i = 1; i <= q; ++i)
    read(a), read(b), printf("%d\n", solve(a, b));
  return 0;
}
