#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")

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

#define pb push_back
#define F first
#define S second

#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 1e5+5, LG = 17, MOD = 998244353;
const int SQ = 390;
const long double EPS = 1e-7;
int n, x[N], L;
int tb[N][17];
int32_t main(){
#ifdef ONLINE_JUDGE
  ios_base::sync_with_stdio(0);
  cin.tie(0);
#endif // ONLINE_JUDGE
  cin >> n;
  f(i,0,n){
    cin >> x[i];
  }
  cin >> L;
  for(int i = 0, j = 0; i < n; i++){
    while(j<n&&x[j]-x[i]<=L)j++;
    tb[i][0] = j - 1;
  }

  f(k,1,17)
    for(int i = 0; i <n; i++)
      tb[i][k] = tb[tb[i][k-1]][k-1];

  int q; cin >> q;
  while(q--){
    int x, y; cin >> x >> y;  --x,--y;
    if(x>y)swap(x,y);
    int ans = 0;
    for(int k = 16; k >= 0; --k)
    if(tb[x][k] < y){
      x = tb[x][k];
      ans += (1 << k);
    }
    cout <<ans+1<<'\n';
  }

  return 0;
}

#include <iostream>
#include <set>
#include <vector>
#include <algorithm>


using namespace std;


static const int MAX = 100000;

vector<int> graph[MAX];
vector<bool> discovered(MAX, false);
vector<int> prenum(MAX, 0), parent(MAX, 0), lowest(MAX, 0);
int V, E;
int t = 0;


void dfs(int vertex, int prev)
{
    prenum[vertex] = lowest[vertex] = ++t;
    discovered[vertex] = true;

    for (auto it = graph[vertex].begin(); it != graph[vertex].end(); ++it) {
        if (!discovered[*it]) {
            parent[*it] = vertex;
            dfs(*it, vertex);
            lowest[vertex] = min(lowest[vertex], lowest[*it]);
        } else if (*it != prev) {
            lowest[vertex] = min(lowest[vertex], prenum[*it]);
        }
    }
}


set<int> arts;
void art_points()
{
    dfs(0, -1);

    int num_root_children = 0;
    for (int i = 1; i < V; i++) {
        int p = parent[i];
        if (p == 0)
            num_root_children++;
        else if (prenum[p] <= lowest[i]) {
            arts.insert(p);
        }
    }

    if (num_root_children > 1) {
        arts.insert(0);
    }

    for (auto it = arts.begin(); it != arts.end(); ++it)
        cout << *it << endl;
}


int main()
{
    cin >> V >> E;

    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        graph[s].push_back(t);
        graph[t].push_back(s);
    }
    art_points();

    return 0;
}

