#include <bits/stdc++.h>
using namespace std;
long long n;
vector<long long> x;
long long l;
long long q;
vector<long long> a;
vector<long long> b;
long long k;
vector<vector<long long> > r;
long long pow(long long a, long long n, long long mod = 1000000007) {
  long long ret = 1;
  for (; n != 0; n = n >> 1) {
    if (n & 1) ret = (ret * a) % mod;
    a = (a * a) % mod;
  }
  return ret;
}
void query(long long a, long long b) {
  long long ans = 0;
  if (a > b) swap(a, b);
  long long t = k;
  while (a < b) {
    long long s = upper_bound(r[a].begin(), r[a].begin() + t, b) - r[a].begin();
    if (t == s)
      break;
    else
      t = s;
    ans += pow(2, t - 1);
    a = r[a][t - 1];
  }
  cout << ans << endl;
}
int main(int argc, char const *argv[]) {
  cin >> n;
  k = 1;
  for (long long m = 1; m < n; m <<= 1) k++;
  x = vector<long long>(n + 1);
  r = vector<vector<long long> >(n + 1, vector<long long>(k));
  for (long long i = 1; i <= n; i++) cin >> x[i];
  cin >> l;
  cin >> q;
  for (long long i = 1; i <= n; i++) {
    r[i][0] = upper_bound(x.begin(), x.end(), x[i] + l) - x.begin() - 1;
  }
  for (long long i = 1; i < k; i++) {
    for (long long j = 1; j <= n; j++) {
      r[j][i] = r[r[j][i - 1]][i - 1];
    }
  }
  a = vector<long long>(q);
  b = vector<long long>(q);
  for (long long i = 0; i < q; i++) cin >> a[i] >> b[i];
  for (long long i = 0; i < q; i++) {
    query(a[i], b[i]);
  }
  return 0;
}
