#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)1e3;
int n, A[MAXN + 5], l, t;
int dist[MAXN + 5][MAXN + 5];
int main() {
  memset(dist, 0x3f, sizeof dist);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &A[i]);
  scanf("%d%d", &l, &t);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n && A[j] <= A[i] + l; j++) dist[i][j] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      for (int k = i; k < j; k++)
        if (dist[i][j] > dist[i][k] + dist[k][j])
          dist[i][j] = dist[i][k] + dist[k][j];
  while (t--) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (u > v) swap(u, v);
    if (u == v) {
      printf("0\n");
      continue;
    }
    printf("%d\n", dist[u][v]);
  }
  return 0;
}
