#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
int n;
int a[N];
int L, q, ans, lst;
int dp[N][21];
int main() {
  memset(dp, 0x3f, sizeof(dp));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  scanf("%d", &L);
  scanf("%d", &q);
  for (int i = 1; i <= n; i++) {
    lst = max(i, lst);
    for (int j = lst; j <= n; j++) {
      if (a[j] - a[i] <= L) {
        lst = j;
      }
    }
    dp[i][0] = lst;
  }
  for (int j = 1; j <= 20; j++) {
    for (int i = 1; i <= n; i++) {
      if (dp[i][j - 1] < 0x3f3f3f3f) dp[i][j] = dp[dp[i][j - 1]][j - 1];
    }
  }
  while (q--) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x > y) swap(x, y);
    ans = 0;
    for (int i = 20; i >= 0; i--) {
      if (dp[x][i] < y) {
        x = dp[x][i];
        ans += (1 << i);
      }
    }
    printf("%d\n", ans + 1);
  }
  return 0;
}
