#include <bits/stdc++.h>
using namespace std;
long long int n, l, q;
vector<long long int> arr;
vector<vector<long long int>> table;
void preprocess() {
  long long int curr = 1;
  long long int i = 1;
  while (i <= n) {
    if (curr == n + 1) {
      table[i][0] = curr - 1;
      i++;
      continue;
    }
    while (curr <= n && (arr[curr] - arr[i]) <= l) {
      curr++;
    }
    table[i][0] = curr - 1;
    i++;
  }
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j < 30; j++) {
      long long int mid = table[i][j - 1];
      if (mid != -1) {
        table[i][j] = table[mid][j - 1];
      }
    }
  }
}
long long int query(long long int l, long long int r) {
  if (l > r) swap(l, r);
  long long int ans = 0;
  for (long long int j = 29; j >= 0; j--) {
    long long int pw = 1LL << j;
    if (table[l][j] == -1) continue;
    if (arr[table[l][j]] < arr[r]) {
      l = table[l][j];
      ans += pw;
    }
  }
  ans++;
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  arr.assign(n + 1, 0);
  table.assign(n + 1, vector<long long int>(30, -1));
  for (long long int i = 1; i <= n; i++) cin >> arr[i];
  cin >> l >> q;
  preprocess();
  while (q--) {
    long long int low, high;
    cin >> low >> high;
    long long int ans = query(low, high);
    cout << ans << endl;
  }
  return 0;
}
