#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MAX = 1e10;
const int BITSIZE = 1 << 17;
const long long p = 7 + 1e9;
const int SIZE = 2 * 1e5;
long long nums[SIZE];
long long doubling[SIZE][20];
long long solve(int a, int b) {
  if (a >= b) return 0;
  for (long long i = (0); i < (long long)(20); i++) {
    int x = 20 - i - 1;
    if (x && doubling[a][x] == doubling[a][x - 1]) continue;
    if (doubling[a][x] <= b || x == 0) {
      return (1LL << x) + solve(doubling[a][x], b);
    }
  }
}
int main() {
  long long N, L, a, b;
  cin.tie(0);
  cin >> N;
  for (long long i = (0); i < (long long)(N); i++) {
    cin >> nums[i];
  }
  cin >> L;
  nums[N] = INF;
  int s = 0;
  long long now = 0;
  for (long long i = (0); i < (long long)(N + 1); i++) {
    while (nums[i] - nums[s] > L) {
      doubling[s++][0] = i - 1;
    }
  }
  doubling[N][0] = N;
  for (long long j = (1); j < (long long)(20); j++) {
    for (long long i = (0); i < (long long)(N + 1); i++) {
      doubling[i][j] = doubling[doubling[i][j - 1]][j - 1];
    }
  }
  long long Q;
  cin >> Q;
  for (long long i = (0); i < (long long)(Q); i++) {
    cin >> a >> b;
    if (a > b) swap(a, b);
    printf("%lld\n", solve(a - 1, b - 1));
  }
  return 0;
}
