#include <bits/stdc++.h>
#pragma warning(disable : 4786)
#pragma warning(disable : 4996)
using namespace std;
int n, x[100005];
int L;
int dp[18][100005];
void preprocess() {
  int end = n;
  for (int i = n; i >= 1; i--) {
    while (x[end] - x[i] > L) end--;
    dp[0][i] = end;
    for (int j = 1; j <= 17; j++) {
      dp[j][i] = dp[j - 1][dp[j - 1][i]];
    }
  }
}
int query(int a, int b) {
  int ret = 0;
  for (int i = 17; i >= 0; i--) {
    if (dp[i][a] >= b) continue;
    ret += 1 << i;
    a = dp[i][a];
  }
  while (a != b) {
    a = dp[0][a];
    ret++;
  }
  return ret;
}
int main() {
  int Q, a, b;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
  scanf("%d", &L);
  preprocess();
  scanf("%d", &Q);
  for (int i = 1; i <= Q; i++) {
    scanf("%d %d", &a, &b);
    if (a > b) swap(a, b);
    printf("%d\n", query(a, b));
  }
  return 0;
}
