#include <bits/stdc++.h>
using namespace std;
long long a[100009][20];
long long b[100009];
long long n, L, test;
signed main() {
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> b[i];
  cin >> L;
  for (long long j = 0; j < 20; j++) {
    if (j == 0) {
      long long id = 0, sum = 0;
      for (long long i = 0; i < n; i++) {
        while (id < n - 1 && sum + (b[id + 1] - b[id]) <= L)
          sum += b[id + 1] - b[id], id++;
        a[i][j] = id;
        if (i != n - 1 && sum) sum -= b[i + 1] - b[i];
      }
    } else {
      for (long long i = 0; i < n; i++) {
        a[i][j] = a[a[i][j - 1]][j - 1];
      }
    }
  }
  cin >> test;
  while (test--) {
    long long l, r;
    cin >> l >> r;
    l--;
    r--;
    if (r < l) swap(l, r);
    long long sum = 0;
    while (l != r) {
      for (long long i = 19; i >= 0; i--) {
        if (a[l][i] > r || (i && a[l][i - 1] <= r)) continue;
        l = a[l][i];
        sum += pow(2, i);
        break;
      }
    }
    cout << sum << endl;
  }
}
