#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int a[MAXN], n, L, go[19][MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  scanf("%d", &L);
  memset(go, 0x3f, sizeof(go));
  for (int i = 1; i <= n; ++i) {
    int p = upper_bound(a + 1, a + n + 1, a[i] + L) - a;
    if (p != n + 1) go[0][i] = p - 1;
  }
  for (int i = 1; i <= 18; ++i)
    for (int j = 1; j <= n; ++j)
      if (go[i - 1][j] != 0x3f3f3f3f) go[i][j] = go[i - 1][go[i - 1][j]];
  int q;
  scanf("%d", &q);
  while (q--) {
    int x, y, ans = 0;
    scanf("%d%d", &x, &y);
    if (x > y) swap(x, y);
    for (int i = 18; i >= 0; --i)
      if (a[go[i][x]] <= a[y]) x = go[i][x], ans += (1 << i);
    if (x == y)
      printf("%d\n", ans);
    else
      printf("%d\n", ans + 1);
  }
  return 0;
}
