int main()
{
	long long N, Q, L;
	vector<long long> loc(1);
	cin >> N;
	long long t;
	for (long long i = 0; i < N; ++i){
		cin >> t;
		loc.push_back(t);
	}
	cin >> L >> Q;
	vector<vector<pair<long long, long long>>> days(N + 1, vector<pair<long long, long long>>(N + 1, { 0, 0 }));
	for (long long i = 1; i < N; ++i){
		for (long long j = i+1; j <= N; ++j){
			long long dist = loc[j] - loc[j - 1];
			if (days[i][j - 1].second>=dist){
				days[i][j] = { days[i][j - 1].first, days[i][j - 1].second - dist };
			}
			else{
				days[i][j] = { days[i][j - 1].first + 1, L - dist };
			}
		}
	}
	vector<long long> a(Q), b(Q);
	for (long long i = 0; i < Q; ++i){
		cin >> a[i] >> b[i];
	}
	for (long long i = 0; i < Q; ++i){
		if (a[i] <= b[i]){
			cout << days[a[i]][b[i]].first << endl;
		}
		else{
			cout << days[b[i]][a[i]].first << endl;
		}
	}
	cin >> N;
	return 0;
}