#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 7;
int go[N], n, l;
int x[N], h[N];
bool used[N];
void bfs(int v) {
  queue<int> q;
  q.push(1);
  used[1] = 1;
  while (!q.empty()) {
    v = q.front();
    q.pop();
    for (int i = v + 1; i <= go[v]; i++) {
      if (!used[i]) {
        used[i] = 1;
        q.push(i);
        h[i] = h[v] + 1;
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", x + i);
  }
  scanf("%d", &l);
  int cur = 2;
  for (int i = 1; i <= n; i++) {
    while (cur <= n && x[cur] - x[i] <= l) {
      cur++;
    }
    cur--;
    go[i] = cur;
  }
  bfs(1);
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b;
    scanf("%d %d", &a, &b);
    int ans;
    if (a > b) swap(a, b);
    ans = h[b] - h[a];
    if (!ans) ans++;
    printf("%d\n", ans);
  }
}
