#include <bits/stdc++.h>
using namespace std;
const int block = 200;
signed main() {
  ios_base::sync_with_stdio();
  cin.tie(0);
  cout.tie(0);
  ;
  int n, l, q, x, y;
  cin >> n;
  int hotel[n];
  for (__typeof(n) i = 0; i < n; i++) cin >> hotel[i];
  cin >> l >> q;
  int skip[n];
  long long t;
  for (__typeof(n) i = 0; i < n; i++) {
    t = hotel[i] + block * l;
    auto it = upper_bound(hotel, hotel + n, t);
    it--;
    skip[i] = it - hotel;
  }
  for (__typeof(n) i = 0; i < n; i++) cout << skip[i] << " ";
  long long cur;
  int pos, step = 0;
  while (q--) {
    cin >> x >> y;
    x--;
    y--;
    if (x > y) swap(x, y);
    if (y < skip[x]) {
      cur = hotel[x];
      step = 0;
      pos = x;
      while (pos < y) {
        cur += l;
        step++;
        auto it = upper_bound(hotel, hotel + n, cur);
        it--;
        pos = it - hotel;
        cur = hotel[pos];
      }
      cout << step << endl;
    } else {
      step = 0;
      pos = x;
      while (skip[pos] < y) {
        pos = skip[pos];
        step += block;
      }
      cur = hotel[pos];
      while (pos < y) {
        cur += l;
        step++;
        auto it = upper_bound(hotel, hotel + n, cur);
        it--;
        if (it == hotel + n) it--;
        pos = it - hotel;
        cur = hotel[pos];
      }
      cout << step << endl;
    }
  }
}
