#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  int l, q;
  cin >> l >> q;
  vector<int> dp(n + 1);
  vector<int> s(n + 1);
  for (int i = 0; i < n; i++) {
    int now = x[i];
    dp[i + 1] = lower_bound(x.begin(), x.end(), now + l + 1) - x.begin();
  }
  s[1] = 0;
  int day = 1;
  int pos = 1;
  while (pos <= n) {
    int next = dp[pos];
    while (pos <= n && next > pos) {
      pos++;
      s[pos] = day;
    }
    if (pos == n) break;
    day++;
  }
  while (q--) {
    int a, b;
    cin >> a >> b;
    int l = min(a, b);
    int h = max(a, b);
    int ans = s[h] - s[l];
    if (ans == 0)
      cout << 1 << endl;
    else
      cout << ans << endl;
  }
}
