#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100005;
vector<vector<int> > memo(MAX_N, vector<int>(18, 1000000005));
int t[18];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < (int)n; ++i) {
    cin >> vec[i];
  }
  int hoge = 1;
  for (int i = 0; i < (int)18; ++i) {
    t[i] = hoge;
    hoge *= 2;
  }
  int mx = 0;
  int bf = n;
  while (bf) {
    bf /= 2;
    mx++;
  }
  mx--;
  for (int i = 0; i < (int)n - 1; ++i) {
    int id = upper_bound((vec).begin(), (vec).end(), vec[i] + 10) - vec.begin();
    memo[i][0] = id - 1;
  }
  memo[n - 1][0] = 1000000005;
  for (int i = 1; i < mx; i++) {
    for (int j = 0; j < (int)n; ++j) {
      if (memo[j][i - 1] < n) {
        memo[j][i] = memo[memo[j][i - 1]][i - 1];
      } else {
        memo[j][i] = 1000000005;
      }
    }
  }
  int L, Q;
  cin >> L >> Q;
  for (int i = 0; i < (int)Q; ++i) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    int a, b;
    a = min(x, y), b = max(x, y);
    int cnt = 0;
    while (1) {
      int id =
          upper_bound((memo[a]).begin(), (memo[a]).end(), b) - memo[a].begin();
      if (id == 0) {
        cout << cnt + 1 << endl;
        break;
      }
      cnt += t[id - 1];
      if (memo[a][id - 1] == b) {
        cout << cnt << endl;
        break;
      } else {
        a = memo[a][id - 1];
      }
    }
  }
  return 0;
}
