#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.14159265358979323846264338327950288;
const long long INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int MAX_N = 100005;
int N, L, Q;
int x[MAX_N];
int Left[MAX_N];
int nL[MAX_N];
int main() {
  cin >> N;
  for (register int i = (1); i <= (N); i++) cin >> x[i], Left[i] = i;
  cin >> L >> Q;
  for (register int i = (2); i <= (N); i++) {
    if (x[i + 1] - x[Left[i - 1]] <= L) Left[i] = Left[i - 1];
  }
  for (register int i = (1); i <= (N); i++) {
    if (Left[i] == Left[i - 1])
      nL[i] = nL[i - 1];
    else
      nL[i] = nL[i - 1] + 1;
  }
  while (Q--) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    int la, lb;
    la = nL[a];
    lb = nL[b];
    cout << lb - la << endl;
  }
  return 0;
}
