#include <bits/stdc++.h>
const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;
using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
bool paircomp(const pair<ll, ll> &a, const pair<ll, ll> &b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first < b.first;
}
ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, L, Q;
  cin >> N;
  vl X(N);
  for (ll i = 0; i < (N); i++) cin >> X[i];
  cin >> L >> Q;
  vvl r = vector<vector<ll>>(20, vector<ll>(N + 1, 0));
  for (ll i = 0; i < (N); i++) {
    r[0][i] = upper_bound((X).begin(), (X).end(), X[i] + 10) - X.begin() - 1;
  }
  for (ll j = (1); j < (20); j++) {
    for (ll i = 0; i < (N); i++) {
      r[j][i] = r[j - 1][r[j - 1][i]];
    }
  }
  vl ans(Q);
  for (ll q = 0; q < (Q); q++) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    ll s = min(a, b);
    ll e = max(a, b);
    ll least = 0;
    ll add = 0;
    ll an = 0;
    for (ll i = (20) - 1; i >= 0; i--) {
      if (e <= r[i][s]) {
        add = POW(2, i);
        an = add + least;
      } else {
        s = r[i][s];
        add = 0;
        least += POW(2, i);
      }
    }
    ans[q] = an;
  }
  for (ll i = 0; i < (Q); i++) cout << ans[i] << endl;
  return 0;
}
