#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q, L;
  vector<int> loc(1);
  cin >> N;
  int t;
  for (int i = 0; i < N; ++i) {
    cin >> t;
    loc.push_back(t);
  }
  cin >> L >> Q;
  vector<vector<pair<int, int>>> days(N + 1,
                                      vector<pair<int, int>>(N + 1, {0, 0}));
  for (int i = 1; i < N; ++i) {
    for (int j = i + 1; j <= N; ++j) {
      int dist = loc[j] - loc[j - 1];
      if (days[i][j - 1].second >= dist) {
        days[i][j] = {days[i][j - 1].first, days[i][j - 1].second - dist};
      } else {
        days[i][j] = {days[i][j - 1].first + 1, L - dist};
      }
    }
  }
  vector<int> a(Q), b(Q);
  for (int i = 0; i < Q; ++i) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < Q; ++i) {
    if (a[i] <= b[i]) {
      cout << days[a[i]][b[i]].first << endl;
    } else {
      cout << days[b[i]][a[i]].first << endl;
    }
  }
  return 0;
}
