#include <bits/stdc++.h>
using namespace std;
int hotel[1005];
int main() {
  int n, L, Q;
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) scanf("%d", &hotel[i]);
    scanf("%d", &L);
    scanf("%d", &Q);
    while (Q--) {
      int a, b;
      scanf("%d%d", &a, &b);
      if (a > b) swap(a, b);
      int day = 0;
      int now = a;
      int i = a;
      while (1) {
        int dis = hotel[i] - hotel[now];
        if (i == b && dis <= L) {
          day++;
          break;
        }
        if (dis < L) {
          i++;
        } else if (dis == L) {
          day++;
          now = i;
        } else {
          now = i - 1;
          day++;
        }
      }
      printf("%d\n", day);
    }
  }
  return 0;
}
