# include <iostream>
# include <cstring>
# include <vector>
# include <cmath>
# include <sstream>
# include <algorithm>
using namespace std;

int N;
int L, Q;
int x[100000];
int dp[100000][100000];


int func(int a, int b){
	if(dp[a-1][b-1] != -1){
		return dp[a-1][b-1];
	}
	int i=1;
	while(a <= b){
		int ad_a = x[a-1];
		int ad_b = x[b-1];
		if(ad_b - ad_a <= 10)
			break;
		while(x[a-1] - ad_a <= 10){
			a++;
		}	
		a--;
		i++;
	}
	return i;
}

int main(){
	cin >> N;
	for(int i=0; i<N; i++)
		cin >> x[i];

	cin >> L >> Q;
	vector<int> out(Q);

	memset(dp, -1, sizeof(dp));

	int a, b;
	for(int i=0; i<Q; i++){
		cin >> a >> b;
		if(a > b)	swap(a, b);
		out[i] = dp[a-1][b-1] = func(a, b);
	}

	for(int i=0; i<Q; i++){
		cout << out[i] << endl;
	}
	return 0;
}