#include <bits/stdc++.h>
using namespace std;
int N;
int L, Q;
int x[100000];
int func(int a, int b) {
  int i = 1;
  while (a <= b) {
    int ad_a = x[a - 1];
    int ad_b = x[b - 1];
    if (ad_b - ad_a <= 10) break;
    while (x[a - 1] - ad_a <= 10) {
      a++;
    }
    a--;
    i++;
  }
  return i;
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> x[i];
  cin >> L >> Q;
  vector<int> out(Q);
  int a, b;
  for (int i = 0; i < Q; i++) {
    cin >> a >> b;
    if (a > b) swap(a, b);
    out[i] = func(a, b);
  }
  for (int i = 0; i < Q; i++) {
    cout << out[i] << endl;
  }
  return 0;
}
