#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int n, L, q;
int a[MAXN], d[MAXN][25];
void Init() {
  for (int i = 1; i <= n; i++) d[i][0] = i;
  int l = 1, r = 1;
  while (r < n) {
    while (r < n && a[r + 1] - a[l] <= L) r++;
    d[l][1] = r;
    l++;
  }
  for (; l <= n; l++) d[l][1] = n;
  for (int i = 2; (1 << i) <= n; i++)
    for (int j = 1; j <= n; j++) d[j][i] = d[d[j][i - 1]][i - 1];
}
bool check(int x, int s, int t) {
  int now = s, jl = 1;
  while (x) {
    if (x & 1) now = d[now][jl];
    x /= 2;
    jl++;
  }
  if (now >= t) return 1;
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  scanf("%d", &L);
  Init();
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int s, t;
    scanf("%d %d", &s, &t);
    if (s > t) swap(s, t);
    if (s == t) {
      printf("0\n");
      continue;
    }
    int l = 0, r = n;
    while (l < r) {
      int mid = (l + r) >> 1;
      if (check(mid, s, t))
        r = mid;
      else
        l = mid + 1;
    }
    printf("%d\n", r);
  }
}
