#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200003;
int n, L, a[MAXN], q, mx, ans, l, r;
int dp[MAXN][19];
void solve() {
  a[n + 1] = 0x3f3f3f3f;
  for (int i = 1; i <= n; ++i) {
    dp[i][0] = lower_bound(a + 1, a + n + 2, a[i] + L + 1) - a - 1;
  }
  for (mx = 1; (1 << mx) <= n; ++mx) {
    for (int i = 1; i <= n; ++i) {
      dp[i][mx] = dp[dp[i][mx - 1]][mx - 1];
    }
  }
  --mx;
  scanf("%d", &q);
  while (q-- > 0) {
    scanf("%d%d", &l, &r);
    if (l > r) {
      swap(l, r);
    }
    ans = 0;
    for (int i = mx; i >= 0; --i) {
      if (dp[l][i] < r) {
        ans += 1 << i;
        l = dp[l][i];
      }
    }
    while (l < r) {
      ++ans;
      l = dp[l][0];
    }
    printf("%d\n", ans);
  }
}
int main() {
  while (1 == scanf("%d", &n)) {
    for (int i = 1; i <= n; ++i) {
      scanf("%d", a + i);
    }
    scanf("%d", &L);
    solve();
  }
  return 0;
}
