#include <bits/stdc++.h>
using namespace std;
long long n;
long long x[100000];
long long a[100001];
long long l;
long long q;
long long from, to;
long long _right[20][100000];
long long _left[20][100000];
long long dist(long long l, long long r) {
  if (l > r) swap(l, r);
  return a[r + 1] - a[l + 1];
}
bool checkL(long long mid) {
  long long i = 19;
  long long pos = from;
  while (i >= 0) {
    if (mid % (1 << i) == 0) pos = _left[i][pos];
    i--;
  }
  return (pos <= to);
}
bool checkR(long long mid) {
  long long i = 19;
  long long pos = from;
  while (i >= 0) {
    if (mid % (1 << i) == 0) pos = _right[i][pos];
    i--;
  }
  return (pos >= to);
}
bool check(long long mid) {
  if (from >= to) return checkL(mid);
  return checkR(mid);
}
signed main() {
  long long i, j;
  cin >> n;
  for (i = 0; i < n; i++) cin >> x[i];
  for (i = 1; i <= n; i++) a[i] = a[i - 1] + x[i - 1];
  cin >> l;
  j = 0;
  for (i = 0; i < n; i++) {
    for (j = max(j, i); j < n && dist(i, j) <= l; j++)
      ;
    j--;
    _right[0][i] = j;
  }
  for (i = 1; i < 20; i++) {
    for (j = 0; j < n; j++) {
      _right[i][j] = _right[i - 1][_right[i - 1][j]];
    }
  }
  j = n - 1;
  for (i = n - 1; i >= 0; i--) {
    for (j = min(j, i); j >= 0 && dist(i, j) <= l; j--)
      ;
    j++;
    _left[0][i] = j;
  }
  for (i = 1; i < 20; i++) {
    for (j = 0; j < n; j++) {
      _left[i][j] = _left[i - 1][_right[i - 1][j]];
    }
  }
  cin >> q;
  for (long long i = 0; i < q; i++) {
    cin >> from >> to;
    long long st = 0, ed = n + 5, mid;
    while (ed - st >= 2) {
      mid = (st + ed) / 2;
      if (check(mid)) {
        ed = mid;
      } else {
        st = mid;
      }
    }
    cout << st << endl;
  }
  return 0;
}
