#include <bits/stdc++.h>
using namespace std;
int n, L, q;
int x[1000001];
int a[1000001], b[1000001];
vector<int> G[1000001];
int dist[1000001];
int bfs(int f, int t) {
  memset(dist, -1, sizeof(dist));
  queue<int> que;
  que.push(f);
  dist[f] = 0;
  while (que.size()) {
    int v = que.front();
    que.pop();
    if (v == t) return dist[t];
    for (int i = 0; i < G[v].size(); i++) {
      if (dist[G[v][i]] == -1) {
        dist[G[v][i]] = dist[v] + 1;
        que.push(G[v][i]);
      }
    }
  }
  return -1;
}
int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
  }
  scanf("%d", &L);
  scanf("%d", &q);
  if (n > 1000 || q > 1000) return 0;
  for (int i = 0; i < n; i++) {
    int all = 0;
    int j = i;
    while (j > 0) {
      all += x[j] - x[j - 1];
      if (all > L) break;
      G[i].push_back(j - 1);
      j--;
    }
    j = i;
    all = 0;
    while (j < n) {
      all += x[j + 1] - x[j];
      if (all > L) break;
      G[i].push_back(j + 1);
      j++;
    }
  }
  for (int i = 0; i < q; i++) {
    scanf("%d%d", &a[i], &b[i]);
    printf("%d\n", bfs(a[i] - 1, b[i] - 1));
  }
  return 0;
}
