#include <bits/stdc++.h>
using namespace std;
int n, len, q;
int num;
int block;
int a[100010];
int b[100010];
int to[100010];
int nxt[100010];
int step[100010];
int find(int x) {
  int ans = 0;
  int l = 1, r = n;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (a[mid] - a[x] <= len) {
      l = mid + 1;
      ans = mid;
    } else {
      r = mid - 1;
    }
  }
  return ans;
}
void build() {
  for (int i = 1; i <= n; i++) {
    to[i] = find(i);
  }
  to[n] = n + 1;
  block = sqrt(n);
  num = ceil(n / block);
  for (int i = 1; i <= n; i++) {
    b[i] = (i - 1) / block + 1;
  }
  for (int i = 1; i <= n; i++) {
    int p = i, cnt = 0;
    while (b[p] == b[i]) {
      p = to[p];
      cnt++;
    }
    nxt[i] = p;
    step[i] = cnt;
  }
}
int query(int x, int y) {
  int res = 0;
  while (x <= y - len) {
    res += step[x];
    x = nxt[x];
  }
  while (x < y) {
    x = to[x];
    res++;
  }
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a + 1, a + n + 1);
  scanf("%d%d", &len, &q);
  build();
  for (int i = 1; i <= q; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x > y) swap(x, y);
    printf("%d\n", query(x, y));
  }
  return 0;
}
