#include <bits/stdc++.h>
using namespace std;
template <class T>
using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
char moji[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
char moji2[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
                  'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
                  'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
char moji3[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
bool Add(long long &a, long long b) { a = (a + b) % long long(1e9 + 7); }
void myprint(long long *A, long long A_num) {
  for (long long i = 0; i < A_num; i++) cout << A[i] << " ";
  cout << endl;
}
const long long n_max = 100005;
signed main() {
  long long n;
  cin >> n;
  long long X[n];
  for (long long i = 0; i < n; i++) cin >> X[i];
  long long L;
  cin >> L;
  long long tugi[n_max][25];
  for (long long i = 0; i < n_max; i++)
    for (long long j = 0; j < 25; j++) tugi[i][j] = n;
  for (long long i = 0; i < n - 1; i++) {
    long long l = i + 1;
    long long r = n;
    while (l + 1 < r) {
      long long mid = (l + r) / 2;
      if (X[mid] - X[i] <= L)
        l = mid;
      else
        r = mid;
    }
    tugi[i][1] = l;
  }
  for (long long j = 0; j < 23; j++) {
    for (long long i = 0; i < n; i++) {
      if (tugi[i][j + 1] == n) tugi[i][j + 2] = n;
      tugi[i][j + 2] = tugi[tugi[i][j + 1]][j + 1];
    }
  }
  long long beki[30];
  beki[1] = 1;
  for (long long i = 1; i < 29; i++) beki[i + 1] = beki[i] * 2;
  long long q;
  cin >> q;
  for (long long i = 0; i < q; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a == b) {
      cout << 0 << endl;
      continue;
    }
    if (a > b) swap(a, b);
    long long id = 24;
    long long now = a;
    long long ans = 0;
    while (now != b) {
      if (tugi[now][id] <= b) {
        now = tugi[now][id];
        ans += beki[id];
      }
      id--;
      if (id == 0) break;
    }
    cout << ans << endl;
  }
}
