#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
const int M = 1000000007;
int n, l, q;
int a[N];
int nxt[20][N];
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    scanf("%d%d", &l, &q);
    for (int i = 1, j = 1; i <= n; i++) {
      while (j <= n && a[j] - a[i] <= l) {
        j++;
      }
      nxt[0][i] = j - 1;
    }
    for (int i = 1; i < 20; i++) {
      for (int j = 1; j <= n; j++) {
        nxt[i][j] = nxt[i - 1][nxt[i - 1][j]];
      }
    }
    for (int i = 0, x, y; i < q; i++) {
      scanf("%d%d", &x, &y);
      if (x == y) {
        puts("0");
        continue;
      }
      if (x > y) {
        swap(x, y);
      }
      int ans = 1;
      for (int i = 19; i >= 0; i--) {
        if (nxt[i][x] < y) {
          ans += 1 << i;
          x = nxt[i][x];
        }
      }
      printf("%d\n", ans);
    }
  }
}
