#include <bits/stdc++.h>
using namespace std;
int dp[100005][20];
int x[100005];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int a, b, n, L, Q;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i];
  cin >> L >> Q;
  for (int i = 0; i < n; i++) {
    int t = upper_bound(x, x + n, x[i] + L) - x;
    if (t == n) {
      if (x[i] + L > x[n - 1])
        dp[i][0] = n;
      else
        dp[i][0] = n - 1;
    } else
      dp[i][0] = t - 1;
  }
  for (int i = 1; i < 20; i++) {
    for (int j = 0; j < n; j++) {
      if (dp[j][i - 1] == n) {
        dp[j][i] = n;
      } else {
        dp[j][i] = dp[dp[j][i - 1]][i - 1];
      }
    }
  }
  for (int i = 0; i < Q; i++) {
    cin >> a >> b;
    a--;
    b--;
    if (x[a] > x[b]) swap(a, b);
    if (a == b) {
      cout << 0 << '\n';
      continue;
    }
    int cur = a, ans = 0;
    for (int i = 19; i >= 0; i--) {
      if (dp[cur][i] != n && x[dp[cur][i]] <= x[b] && cur != dp[cur][i]) {
        cur = dp[cur][i], ans += (1 << i);
      }
    }
    cout << ans << '\n';
  }
}
