#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll << 50;
template <typename T>
void printv(const vector<T>& s) {
  for (int i = 0; i < (int)(s.size()); ++i) {
    cout << s[i];
    if (i == (int)(s.size()) - 1)
      cout << endl;
    else
      cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<ll> x(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }
  vector<ll> diff(n);
  for (int i = 0; i < n - 1; ++i) {
    diff[i] = x[i + 1] - x[i];
  }
  ll l;
  cin >> l;
  map<int, int> arg;
  vector<map<int, int>> mat(n);
  map<int, vector<ll>> mp;
  map<int, vector<int>> day;
  for (int i = 0; i < n - 1; ++i) {
    if (mat[i][diff[i]]) {
      arg[i] = mat[i][diff[i]];
    } else {
      vector<ll> su(n - 1);
      vector<int> d(n - 1);
      ll nowsu = diff[i];
      int nowd = 1;
      su[i] = nowsu;
      d[i] = nowd;
      for (int j = i + 1; j < n - 1; ++j) {
        if (nowsu + diff[j] <= l) {
          nowsu += diff[j];
        } else {
          nowd++;
          nowsu = diff[j];
        }
        su[j] = nowsu;
        d[j] = nowd;
        mat[j][nowsu] = i + 1;
      }
      mp[i] = su;
      day[i] = d;
    }
  }
  int q;
  cin >> q;
  while (q > 0) {
    q--;
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    if (arg[a]) {
      cout << day[arg[a] - 1][b - 1] - day[arg[a] - 1][a - 1] << endl;
    } else {
      cout << day[a][b - 1] << endl;
    }
  }
}
