#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  char c;
  bool nega = 0;
  while ((!isdigit(c = getchar())) && (c != '-'))
    ;
  if (c == '-') {
    nega = 1;
    c = getchar();
  }
  x = c - 48;
  while (isdigit(c = getchar())) x = x * 10 + c - 48;
  if (nega) x = -x;
}
template <typename T>
inline void writep(T x) {
  if (x > 9) writep(x / 10);
  putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  writep(x);
}
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
int x[100001], l;
int f[100001][21];
int ans[100001];
int n, q, a, b;
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    query[100001];
int main() {
  read(n);
  for (int i = 1; i <= n; i++) read(x[i]);
  read(l);
  read(q);
  for (int i = 1; i <= q; i++) {
    read(a);
    read(b);
    if (a > b) swap(a, b);
    query[a].push(make_pair(b, i));
  }
  f[n][0] = n;
  for (int i = n - 1; i >= 1; i--) {
    f[i][0] = f[i + 1][0];
    while (x[f[i][0]] - x[i] > l) f[i][0]--;
  }
  for (int j = 1, r = 2; r <= n; j++, r <<= 1) {
    for (int i = 1; f[i][j - 1] < n; i++) f[i][j] = f[f[i][j - 1]][j - 1];
  }
  pair<int, int> p;
  for (int i = 1; i <= n; i++) {
    int j = 0, r = 1;
    while (!query[i].empty()) {
      p = query[i].top();
      query[i].pop();
      while (f[i][j] < p.first) {
        r <<= 1;
        j++;
      }
      if (j == 0)
        ans[p.second]++;
      else {
        ans[p.second] += r >> 1;
        query[f[i][j - 1]].push(p);
      }
    }
  }
  for (int i = 1; i <= q; i++) writeln(ans[i]);
}
