#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
int n;
int x[101010];
int l, q;
int p[30][101010];
int main() {
  cin >> n;
  for (int i = (0); i < (n); i++) cin >> x[i];
  cin >> l;
  x[n] = INF;
  for (int i = (0); i < (n + 1); i++) {
    p[0][i] = upper_bound(x, x + n + 1, x[i] + l) - 1 - x;
  }
  for (int i = 1; i <= 16; i++) {
    for (int j = (0); j < (n + 1); j++) {
      p[i][j] = p[i - 1][p[i - 1][j]];
    }
  }
  int q;
  cin >> q;
  for (int i = (0); i < (q); i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    int pos = a, ans = 0;
    for (int i = 16; i >= 0; i--) {
      if (p[i][pos] <= b) {
        pos = p[i][pos];
        ans += 1 << i;
      }
    }
    if (pos < b) ans++;
    cout << ans << endl;
  }
}
