#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 5;
const int MAXDEPTH = 17 + 3;
int N, Q, L;
int X[MAXN];
int farthest[MAXN][MAXDEPTH + 1];
int main() {
  int u, v;
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> X[i];
  cin >> L;
  int cur = 1;
  for (int i = 1; i <= N; i++) {
    cur = i + 1;
    while (cur <= N && X[cur] - X[i] <= L) {
      farthest[i][0] = cur;
      cur++;
    }
  }
  for (int k = 1; k < MAXDEPTH; k++)
    for (int i = 1; i < N; i++)
      farthest[i][k] = farthest[farthest[i][k - 1]][k - 1];
  for (int i = 1; i <= N; i++) {
    copy(&farthest[i][0], &farthest[i][MAXDEPTH],
         ostream_iterator<int>(cerr, " "));
    cerr << endl;
  }
  cin >> Q;
  while (Q--) {
    int ans = 0;
    cin >> u >> v;
    if (v < u) swap(u, v);
    for (int i = MAXDEPTH - 1; i >= 0; i--) {
      if (farthest[u][i] != 0 && farthest[u][i] < v) {
        u = farthest[u][i];
        ans += (1 << i);
      }
    }
    cout << ans + 1 << endl;
  }
}
