#include <bits/stdc++.h>
using namespace std;
int n, q, l, v[100000];
vector<vector<pair<int, int> > > dp, pre;
vector<vector<int> > b;
void calcBucket(vector<pair<int, int> > &dp, vector<pair<int, int> > &pre,
                vector<int> &v) {
  assert(!v.empty());
  int n = v.size();
  dp.resize(n);
  pre.resize(n);
  deque<pair<int, pair<int, int> > > q;
  for (int i = n - 1; i >= 0; --i) {
    while (!q.empty() && q.front().first - v[i] > l) q.pop_front();
    if (v[n - 1] - v[i] <= l)
      dp[i] = make_pair(1, -i);
    else {
      dp[i] = q.front().second;
      ++dp[i].first;
    }
    while (!q.empty() && q.back().second >= dp[i]) q.pop_back();
    q.push_back(make_pair(v[i], dp[i]));
  }
  pre[0] = dp[0];
  for (int i = 1; i < n; ++i) pre[i] = min(dp[i], pre[i - 1]);
}
int main() {
  scanf("%d", &n);
  int last = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", v + i);
    int tmp = v[i];
    v[i] -= last;
    last = tmp;
    if (i) v[i] += v[i - 1];
  }
  scanf("%d", &l);
  int Z = n;
  b.resize((n + Z - 1) / Z);
  for (int i = 0; i < n; ++i) b[i / Z].push_back(v[i]);
  dp.resize(b.size());
  pre.resize(b.size());
  for (int i = 0; i < dp.size(); ++i) {
    calcBucket(dp[i], pre[i], b[i]);
  }
  vector<vector<int> > &B = b;
  scanf("%d", &q);
  vector<pair<int, int> > L, R, pL, pR;
  vector<int> vL, vR;
  int a, b;
  while (q--) {
    scanf("%d%d", &a, &b);
    --a;
    --b;
    if (a > b) swap(a, b);
    int res = 0;
    if (a == b)
      ;
    else if (a / Z + 1 >= b / Z) {
      vL.clear();
      for (int i = a; i <= b; ++i) vL.push_back(v[i]);
      calcBucket(L, pL, vL);
      res = L[0].first;
    } else {
      int x = a / Z * Z + Z;
      int y = b / Z * Z - 1;
      vL.clear();
      vR.clear();
      for (int i = a; i < x; ++i) vL.push_back(v[i]);
      for (int i = y + 1; i <= b; ++i) vR.push_back(v[i]);
      calcBucket(L, pL, vL);
      calcBucket(R, pR, vR);
      pair<int, int> last = L[0];
      int remLast = l - (vL.back() - vL[-last.second]);
      res = last.first;
      for (int i = (x - 1) / Z + 1; i <= y / Z; ++i) {
        int at = upper_bound(B[i].begin(), B[i].end(), B[i][0] + remLast) -
                 B[i].begin() - 1;
        if (at == -1) {
          ++res;
          remLast = l;
          at = upper_bound(B[i].begin(), B[i].end(), B[i][0] + remLast) -
               B[i].begin() - 1;
        } else if (B[i].back() - B[i][0] <= remLast) {
          remLast -= B[i].back() - B[i][0];
          continue;
        }
        res += pre[i][at].first;
        last = pre[i][at];
        remLast = l - (B[i].back() - B[i][-last.second]);
      }
      int at =
          upper_bound(vR.begin(), vR.end(), vR[0] + remLast) - vR.begin() - 1;
      if (at == -1) {
        ++res;
        remLast = l;
        at =
            upper_bound(vR.begin(), vR.end(), vR[0] + remLast) - vR.begin() - 1;
      }
      if (vR.back() - vR[0] > remLast) {
        res += pR[at].first;
      }
      ++res;
    }
    printf("%d\n", res);
  }
  return 0;
}
