#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, l, q;
int par[N];
bool used[N];
vector<int> events, v;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    v.push_back(x);
  }
  scanf("%d", &l);
  scanf("%d", &q);
  events.push_back(0);
  memset(used, 0, sizeof(used));
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      int now = i - 1;
      while (now < v.size() - 1) {
        int cur = v[now];
        int pos = lower_bound(v.begin(), v.end(), cur + l) - v.begin();
        if (pos >= v.size() || v[pos] > cur + l) pos--;
        now = pos;
        par[now] = i;
        used[now] = true;
        events.push_back(now);
      }
      break;
    }
  }
  while (q--) {
    int x, y;
    scanf("%d %d", &x, &y);
    if (x > y) swap(x, y);
    x--;
    y--;
    int pos = lower_bound(events.begin(), events.end(), x) - events.begin();
    int pos2 = lower_bound(events.begin(), events.end(), y) - events.begin();
    if (events[pos] != x) pos--;
    printf("%d\n", pos2 - pos);
  }
  return 0;
}
