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