#include <bits/stdc++.h>
using namespace std;
int read() {
  int f = 1, x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
  return x;
}
const int N = 100005;
int n, L, q;
int x[N], r[N][20];
int idx[N];
int main() {
  freopen("A.in", "r", stdin);
  freopen("A.out", "w", stdout);
  n = read();
  x[n + 1] = 1E9 + 7;
  x[0] = -1E9 - 7;
  for (int i = 2; i <= n; i++) idx[i] = idx[i >> 1] + 1;
  for (int i = 1; i <= n; i++) x[i] = read();
  L = read();
  q = read();
  for (int i = 1; i <= n; i++) {
    int le = i, ri = n + 1;
    while (ri - le > 1) {
      int mid = (le + ri) >> 1;
      if (x[mid] - x[i] <= L)
        le = mid;
      else
        ri = mid;
    }
    r[i][0] = le;
  }
  for (int j = 1; j < 18; j++)
    for (int i = 1; i <= n; i++) {
      r[i][j] = r[r[i][j - 1]][j - 1];
    }
  for (int i = 1; i <= q; i++) {
    int a = read(), b = read();
    if (b < a) swap(a, b);
    int ans = 0;
    for (int j = 17; j >= 0; j--) {
      if (r[a][j] < b) {
        a = r[a][j];
        ans += (1 << j);
      }
    }
    printf("%d\n", ans + 1);
  }
  return 0;
}
