#include <bits/stdc++.h>
using namespace std;
int N, Q;
int L;
vector<int> x = {0};
int memo[20][100010];
void build() {
  for (int i = 1; i <= N; i++) {
    memo[0][i] = (upper_bound(x.begin(), x.end(), x[i] + L) - x.begin()) - 1;
  }
  for (int i = 0; i < 19; i++) {
    for (int j = 1; j <= N; j++) {
      memo[i + 1][j] = memo[i][memo[i][j]];
    }
  }
}
int solve(int a, int b) {
  int res = 0;
  for (int i = 0; i < 20; i++) {
    if (memo[i][a] == b) {
      res = 1 << i;
      break;
    }
    if (memo[i][a] > b) {
      res = (1 << (i - 1));
      if (i != 0) res += solve(memo[i - 1][a], b);
      break;
    }
  }
  return res;
}
int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    int tmp;
    cin >> tmp;
    x.push_back(tmp);
  }
  cin >> L;
  build();
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int a, b;
    cin >> a >> b;
    cout << solve(min(a, b), max(a, b)) << endl;
  }
  return 0;
}
