#include <bits/stdc++.h>
using namespace std;
int v[100003];
vector<int> bf[100003];
int L;
int n;
bitset<100003> viz;
int day(int x, int y) {
  int da = 0;
  queue<pair<int, int>> bfs;
  bfs.push({x, 0});
  for (int i = 1; i <= n; i++) viz[i] = 0;
  while (!bfs.empty()) {
    x = bfs.front().first;
    da = bfs.front().second;
    bfs.pop();
    if (viz[x]) continue;
    viz[x] = 1;
    if (x == y) return da;
    for (int j = 0; j < bf[x].size(); j++) {
      if (viz[bf[x][j]]) continue;
      bfs.push({bf[x][j], da + 1});
    }
  }
  return da;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> v[i];
  int Q, x, y;
  cin >> L >> Q;
  for (int i = 1; i <= n; i++) {
    int j = i + 1;
    while (j <= n && v[j] - v[i] <= L) bf[i].push_back(j++);
    j = i - 1;
    while (j > 0 && v[i] - v[j] <= L) bf[i].push_back(j--);
  }
  for (int i = 1; i <= Q; i++) {
    cin >> x >> y;
    cout << day(x, y) << '\n';
  }
  return 0;
}
