#include <bits/stdc++.h>
using namespace std;
int n, q, l;
long long v[100004];
int dp[100004];
int main() {
  scanf("%d", &n);
  int last = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%lld", v + i);
    int tmp = v[i];
    v[i] -= last;
    last = tmp;
    if (i) v[i] += v[i - 1];
  }
  v[n + 1] = v[n] = v[n - 1];
  scanf("%d", &l);
  for (int i = n - 1; i >= 0; --i) {
    int nxt = upper_bound(v, v + n + 2, v[i] + l) - v - 1;
    dp[i] = 1 + dp[nxt];
  }
  scanf("%d", &q);
  int a, b;
  while (q--) {
    scanf("%d%d", &a, &b);
    --a;
    --b;
    if (a > b) swap(a, b);
    printf("%d\n", dp[a] - dp[b]);
  }
  return 0;
}
