#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105000;
int n;
int x[MAXN];
int go[MAXN];
int len;
int qn;
vector<pair<int, int>> q[MAXN];
int stN = 0;
set<pair<int, pair<int, int>>> st[MAXN];
int stNum[MAXN];
int cnt[MAXN];
int ans[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
  }
  scanf("%d", &len);
  scanf("%d", &qn);
  for (int i = 0; i < qn; i++) {
    int from, to;
    scanf("%d %d", &from, &to);
    from--;
    to--;
    if (from > to) {
      swap(from, to);
    }
    q[from].push_back({to, i});
  }
  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      go[i] = i;
      continue;
    }
    int l = i + 1, r = n - 1;
    while (l < r) {
      int mid = (l + r + 1) / 2;
      if (x[mid] - x[i] <= len) {
        l = mid;
      } else {
        r = mid - 1;
      }
    }
    go[i] = l;
  }
  memset(stNum, -1, sizeof(stNum));
  for (int i = 0; i < n; i++) {
    if (stNum[i] == -1) {
      stN++;
      stNum[i] = stN - 1;
    }
    for (auto curQ : q[i]) {
      int to = curQ.first, idx = curQ.second;
      if (to <= go[i]) {
        ans[idx] = 1;
        continue;
      }
      st[stNum[i]].insert({to, {idx, cnt[stNum[i]]}});
    }
    while ((int)st[stNum[i]].size()) {
      auto curQ = *(st[stNum[i]].begin());
      int to = curQ.first, idx = curQ.second.first, f = curQ.second.second;
      if (to <= go[i]) {
        ans[idx] = cnt[stNum[i]] - f + 1;
        st[stNum[i]].erase(curQ);
      } else {
        break;
      }
    }
    if (stNum[go[i]] == -1) {
      stNum[go[i]] = stNum[i];
    } else {
      int otherNum = stNum[go[i]];
      if ((int)st[stNum[i]].size() < (int)st[otherNum].size()) {
        for (auto x : st[stNum[i]]) {
          st[otherNum].insert(x);
        }
      } else {
        for (auto x : st[otherNum]) {
          st[stNum[i]].insert(x);
        }
        stNum[go[i]] = stNum[i];
      }
    }
    cnt[stNum[i]]++;
  }
  for (int i = 0; i < qn; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
