#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define RREP(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define NL cerr << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int from, to; int cost; };
ostream& operator << (ostream& s, const edge& e) {
   s << "(" << e.from << "->" << e.to << ": " << e.cost << ")";
   return s;
}
bool operator< (const edge &edge1, const edge &edge2){
   return edge1.cost < edge2.cost;
};

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T> ostream& operator << (ostream& s, const set<T>& se) {
   s << "{";
   for (auto i = se.begin(); i != se.end(); ++i) {
      s << *i;
      if (next(i) != se.end()) s << ", ";
   }
   s << "}";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const map<T1,T2>& m) {
   s << "{";
   for (auto i = m.begin(); i != m.end(); ++i) {
      s << i->first << ":" << i->second;
      if (next(i) != m.end()) s << ", ";
   }
   s << "}";
   return s;
}

vec<vec<int>> r;

bool check(int d, int a, int b) {
   int k = 0;
   while (d > 0) {
      if (d & 1) {
         a = r[k][a];
      }
      k++;
      d >>= 1;
   }
   return b <= a;
}

int binary_search(int MAX, int a, int b)
{
   int m, l = -1, r = MAX;
   while (r - l > 1) {
      m = (l + r) / 2;
      if (check(m, a, b)) {
         r = m;
      } else {
         l = m;
      }
   }
   return r;
}

signed main()
{
   int N; cin >> N;
   vec<int> x(N);
   REP(i, 0, N) {
      cin >> x[i];
   }
   int L, Q; cin >> L >> Q;
   vec<int> a(Q), b(Q);
   REP(i, 0, Q) {
      cin >> a[i] >> b[i];
      a[i]--; b[i]--;
   }

   int MAX_K = (int)(log(N)/log(2));
   DUMP(MAX_K)
   r.resize(MAX_K+1, vec<int>(N-1));
   REP(i, 0, N-1) {
      r[0][i] = UB(x, x[i]+L) - 1;
   }
   DUMP(r[0])
   REP(k, 0, MAX_K) {
      REP(i, 0, N-1) {
         if (r[k][i] == N-1) {
            r[k+1][i] = N-1;
         } else {
            r[k+1][i] = r[k][r[k][i]];
         }
      }
   }
   DUMP(r)

   REP(i, 0, Q) {
      cout << binary_search(N, min(a[i],b[i]), max(a[i],b[i])) << endl;
   }

   return 0;
}
