#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int x[100000];
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
  }
  int l, q;
  scanf("%d", &l);
  scanf("%d", &q);
  vector<int> s[100000];
  int p[100000];
  for (int i = 0; i < n; i++) {
    p[i] = upper_bound(x, x + n, x[i] + l) - x - 1;
  }
  set<int> s1;
  for (int i = 0; i < n; i++) {
    s1.insert(i);
  }
  int num[100000];
  fill(num, num + n, -1);
  int c = 0;
  while (!s1.empty()) {
    auto itr = s1.begin();
    int j = *itr;
    s[c].push_back(x[j]);
    s1.erase(itr);
    num[j] = c;
    while (p[j] > j) {
      j = p[j];
      if (num[j] == -1) {
        num[j] = c;
        s1.erase(j);
      }
      s[c].push_back(x[j]);
    }
    c++;
  }
  for (int i = 0; i < q; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--;
    b--;
    if (a > b) swap(a, b);
    int m = lower_bound(s[num[a]].begin(), s[num[a]].end(), x[b]) -
            lower_bound(s[num[a]].begin(), s[num[a]].end(), x[a]);
    printf("%d\n", m);
  }
  return 0;
}
