#include <bits/stdc++.h>
using namespace std;
const long long MAX = 200000;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double PI = 3.1415926535897932;
long long N, L, Q, ans = 0, tmp = 0;
vector<long long> A;
vector<vector<long long>> C;
string S;
signed main() {
  cin >> N;
  C.resize(20, vector<long long>(N, 0));
  for (long long i = 0; i < N; i++) {
    long long a;
    cin >> a;
    A.push_back(a);
  }
  cin >> L >> Q;
  for (long long i = 1; i < N; i++) {
    long long id = lower_bound(A.begin(), A.end(), A[i] - L) - A.begin();
    C[0][i] = id;
  }
  cout << "OK" << endl;
  for (long long i = 1; i < 20; i++) {
    for (long long j = 1; j < N; j++) {
      C[i][j] = C[i - 1][C[i - 1][j]];
    }
  }
  cout << "OK" << endl;
  for (long long i = 0; i < Q; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    ans = 0;
    if (a > b) swap(a, b);
    for (long long j = 19; j >= 0; j--) {
      if (C[j][b] > a) {
        b = C[j][b];
        ans += pow(2, j);
      }
    }
    cout << ans + 1 << endl;
  }
  return 0;
}
