#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
long long mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
long long llmax = 9223372036854775807;
long long llmin = -9223372036854775807;
int iinf = intmax / 8;
long long inf = llmax / 8;
double eps = 1e-12;
int main() {
  long long N;
  cin >> N;
  long long x[N];
  for (long long i = (long long)0; i < (long long)N; i++) {
    cin >> x[i];
  }
  long long L;
  cin >> L;
  long long next[N - 1];
  for (long long i = (long long)0; i < (long long)N - 1; i++) {
    long long id = upper_bound(x, x + N, x[i] + L) - x - 1;
    next[i] = id;
  }
  long long Q;
  cin >> Q;
  for (long long i = (long long)0; i < (long long)Q; i++) {
    long long a, b;
    cin >> a >> b;
    if (a > b) {
      swap(a, b);
    }
    long long num = a - 1;
    long long ans = 0;
    while (num < b - 1) {
      num = next[num];
      ans++;
    }
    cout << ans << endl;
  }
}
