#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005, BLK = 320;
struct Query {
  int l, r, id;
  bool operator<(const Query &t) const {
    if (l / BLK == t.l / BLK) return r < t.r;
    return l < t.l;
  }
};
int N, L, Q;
int x[MAXN], left[MAXN], right[MAXN];
Query q[MAXN];
int ans[MAXN];
int dis[MAXN];
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%d", &x[i]);
  scanf("%d%d", &L, &Q);
  for (int i = 1; i <= N; i++)
    left[i] = lower_bound(x + 1, x + N + 1, x[i] - L) - x;
  for (int i = 1; i <= N; i++) {
    right[i] = lower_bound(x + 1, x + N + 1, x[i] + L) - x;
    if (x[right[i]] > x[i] + L) right[i]--;
  }
  for (int i = 2; i <= N; i++) dis[i] = dis[left[i]] + 1;
  for (int i = 1; i <= Q; i++) {
    scanf("%d%d", &q[i].l, &q[i].r);
    if (q[i].l > q[i].r) swap(q[i].l, q[i].r);
    printf("%d\n", dis[q[i].r] - dis[q[i].l - 1]);
    q[i].id = i;
  }
  sort(q + 1, q + Q + 1);
  return 0;
}
