#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MOD2 = 998244353;
const long long MOD3 = 1812447359;
const long long INF = 1ll << 62;
const double PI = 2 * asin(1);
void yes() { printf("yes\n"); }
void no() { printf("no\n"); }
void Yes() { printf("Yes\n"); }
void No() { printf("No\n"); }
void YES() { printf("YES\n"); }
void NO() { printf("NO\n"); }
int N;
long long X[int(1e5 + 5)], L;
int Doubling[int(1e5 + 5)][40];
int Solve() {
  int A, B;
  cin >> A >> B;
  if (A > B) swap(A, B);
  long long ans = 0;
  while (A != B) {
    for (int i = 0; i < 40; i++) {
      if (Doubling[A][i + 1] == 0 || Doubling[A][i + 1] > B) {
        A = Doubling[A][i];
        ans += (long long)1 << i;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> X[i];
  cin >> L;
  int now = 1;
  for (int i = 1; i <= N; i++) {
    while (X[now + 1] - X[i] <= L && now <= N) now++;
    Doubling[i][0] = now;
  }
  for (int j = 1; j < 40; j++) {
    for (int i = 1; i <= N; i++) {
      int next = Doubling[i][j - 1];
      Doubling[i][j] = Doubling[next][j - 1];
    }
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) Solve();
  return 0;
}
