#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N, L, Q;
  cin >> N;
  vector<int> x(N);
  REP(i,N) cin >> x[i];
  cin >> L >> Q;

  vector<vector<int>> r(20, vector<int> (N));
  REP(i,N) {
    r[0][i] = upper_bound(ALL(x), x[i] + L) - x.begin() - 1;
  }
  REP(k,19)REP(i,N) r[k + 1][i] = r[k][r[k][i]];

  REP(i,Q) {
    int a, b;
    cin >> a >> b; --a; --b;
    if(a > b) swap(a, b);
    int res = 0;
    for(int j = 19; j >= 0; --j) {
      if(r[j][a] < b) {
        a = r[j][a];
        res += (1 << j);
      }
    }
    cout << res + 1 << endl;
  }
  return 0;
}

