#include <bits/stdc++.h>
using namespace std;
int N, L, Q;
int x[100010];
int t[100010][17];
int p[17];
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &x[i]);
  }
  scanf("%d%d", &L, &Q);
  int si = 1, se = 1;
  while (se < N) {
    if (x[se + 1] - x[si] <= L) {
      se++;
    } else {
      t[si][0] = se;
      si++;
    }
  }
  for (int i = si; i <= N; i++) {
    t[i][0] = se;
  }
  int k = int(log(N - 1) / log(2));
  int temp = 1;
  for (int i = 1; i <= k; i++) {
    p[i - 1] = temp;
    for (int j = 1; j <= N; j++) {
      t[j][i] = t[t[j][i - 1]][i - 1];
    }
    temp *= 2;
  }
  p[k] = temp;
  int a, b, c;
  for (int i = 1; i <= Q; i++) {
    scanf("%d%d", &a, &b);
    if (a > b) {
      temp = a;
      a = b;
      b = temp;
    }
    temp = a;
    c = 0;
    for (int j = k; k >= 0; j--) {
      if (b >= t[temp][j]) {
        temp = t[temp][j];
        c += p[j];
        if (b == temp) {
          break;
        }
      }
    }
    printf("%d\n", c);
  }
  return 0;
}
