#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int INF = 1 << 29;
const double EPS = 1e-8;
int dist[1000][1000];
bool viewed[1000];
int main() {
  int N;
  cin >> N;
  assert(N <= 1000);
  vector<int> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  int L, Q;
  cin >> L >> Q;
  vector<vector<int>> G(N);
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (x[j] - x[i] <= L) {
        G[i].push_back(j);
        G[j].push_back(i);
      }
    }
  }
  memset(dist, 0, sizeof(dist));
  memset(viewed, 0, sizeof(viewed));
  for (int i = 0; i < N - 1; i++) {
    queue<pair<int, int>> que;
    que.emplace(0, i);
    while (que.size()) {
      pair<int, int> p = que.front();
      que.pop();
      for (int j = p.second + 1; j < N && x[j] - x[p.second] <= L; j++) {
        if (dist[i][j] > 0) continue;
        dist[i][j] = p.first + 1;
        que.emplace(p.first + 1, j);
      }
    }
  }
  for (int i = 0; i < Q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    cout << dist[a][b] << endl;
  }
  return 0;
}
