#include <bits/stdc++.h>
using namespace std;
int N;
long long X[100005];
long long L;
int Q;
int A[100005], B[100005];
map<int, int> MAP;
void input() {
  cin >> N;
  for (size_t i = 0; i < N; i++) {
    cin >> X[i];
    MAP[X[i]] = i + 1;
  }
  cin >> L;
  cin >> Q;
  for (size_t i = 0; i < Q; i++) {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
    if (A[i] > B[i]) {
      swap(A[i], B[i]);
    }
  }
}
int m_next[100005][21];
int calc(int pos) {
  int l = pos, r = N;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (X[mid] - X[pos] <= L) {
      l = mid;
    } else {
      r = mid;
    }
  }
  return l;
}
int main() {
  input();
  for (size_t i = 0; i < N; i++) {
    m_next[i][0] = calc(i);
  }
  m_next[N - 1][0] = -1;
  for (size_t j = 0; j < 21 - 1; j++) {
    for (size_t i = 0; i < N; i++) {
      int n = m_next[i][j];
      if (n == -1) {
        m_next[i][j + 1] = -1;
      } else {
        m_next[i][j + 1] = m_next[n][j];
      }
    }
  }
  for (size_t i = 0; i < Q; i++) {
    int ans = 0;
    int pos = A[i];
    while (pos != B[i]) {
      int N = -1;
      for (size_t i = 0; i < 21; i++) {
        if (m_next[pos][i] > B[i] || m_next[pos][i] == -1) {
          N = i;
          break;
        }
      }
      ans += (1 << (N - 1));
      pos = m_next[pos][N - 1];
    }
    cout << ans << endl;
  }
  return 0;
}
