#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
int n, L, q;
int x[maxn];
int s[maxn];
int solve(int a, int b) {
  if (a > b) swap(a, b);
  int ret = 0;
  int i = a, j = a;
  int tmp = 0;
  while (i < b) {
    while (tmp < L) {
      tmp += x[i++];
    }
    j = i;
    i++;
    ret++;
  }
  return ret;
}
int main() {
  int a, b;
  while (~scanf("%d", &n)) {
    memset((s), 0, sizeof(s));
    memset((x), 0, sizeof(x));
    for (int i = (1); i < (n + 1); i++) {
      scanf("%d", &x[i]);
      s[i] = s[i - 1] + x[i];
    }
    scanf("%d", &L);
    scanf("%d", &q);
    while (q--) {
      scanf("%d", &a);
      scanf("%d", &b);
      printf("%d\n", solve(a, b));
    }
  }
  return 0;
}
