#include <bits/stdc++.h>
using namespace std;
int n, l, q, t, ans, bo, xi, x, y, qx, qx1, zy, zy1, a[2000];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  cin >> l >> q;
  for (int i = 1; i <= q; i++) {
    t = 1;
    ans = 0;
    bo = 0;
    xi = 0;
    scanf("%d%d", &x, &y);
    qx = a[x];
    zy = a[y];
    qx1 = qx;
    zy1 = zy;
    if (qx == zy) {
      cout << "0\n";
      continue;
    }
    while (qx < zy) {
      qx1 += l;
      for (int j = t; j <= n; j++)
        if (a[j] > qx1) {
          xi = j - 1;
          break;
        }
      qx = a[xi];
      t = xi;
      ans++;
      qx1 = qx;
      if (qx == zy) {
        cout << ans << "\n";
        bo = 1;
        break;
      }
    }
    if (bo) continue;
    while (qx > zy) {
      qx1 -= l;
      for (int j = y; j <= n; j++)
        if (a[j] >= qx1) {
          xi = j;
          break;
        }
      qx = a[xi];
      t = xi;
      ans++;
      qx1 = qx;
      if (qx == zy) {
        cout << ans << "\n";
        bo = 1;
        break;
      }
    }
    if (bo) continue;
  }
  return 0;
}
