#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 7;
int go[N], n, l;
int x[N];
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 (x[cur] - x[i] <= l && cur <= n) {
      cur++;
    }
    cur--;
    go[i] = cur;
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b;
    scanf("%d %d", &a, &b);
    int ans = 0;
    if (a > b) swap(a, b);
    int cur = a;
    while (cur < b) {
      cur = go[cur];
      ans++;
    }
    printf("%d\n", ans);
  }
}
