#include <bits/stdc++.h>
using namespace std;
int n, L, m;
int a[100010];
int find(int x) {
  int l = x + 1, r = n, ans = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (a[mid] - a[x] <= L)
      l = mid + 1, ans = mid;
    else
      r = mid - 1;
  }
  return ans - x;
}
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", &L, &m);
  for (int i = 1; i <= m; i++) {
    int x, y, ans = 0;
    scanf("%d%d", &x, &y);
    if (y < x) swap(x, y);
    while (x <= y) {
      x += find(x);
      ans++;
    }
    printf("%d\n", ans - 1);
  }
  return 0;
}
