#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 9,LOGN = 20,INF = 0x3f3f3f3f3f3f3f3f;
int n,q,logn,x;
multiset<pair<int,int> > s;
int h[N];
int dist(int i,int j){
return abs(h[i] - h[j]);
}
int Next[N][LOGN][2];
int dis_a[N][LOGN][2],dis_b[N][LOGN][2];
void init(){
for(int j = 1;j <= logn;j++)
for(int i = 1;i <= n;i++)
for(int k = 0;k <= 1;k++){
if(j == 1){
Next[i][j][k] = Next[Next[i][j - 1][k]][j - 1][1 - k];
dis_a[i][j][k] = dis_a[i][j - 1][k] + dis_a[Next[i][0][k]][j - 1][1 - k];
dis_b[i][j][k] = dis_b[i][j - 1][k] + dis_b[Next[i][0][k]][j - 1][1 - k];
}
else{
Next[i][j][k] = Next[Next[i][j - 1][k]][j - 1][k];
dis_a[i][j][k] = dis_a[i][j - 1][k] + dis_a[Next[i][j - 1][k]][j - 1][k];
dis_b[i][j][k] = dis_b[i][j - 1][k] + dis_b[Next[i][j - 1][k]][j - 1][k];
}
}
}
pair<int,int> calc(int pos,int x){
int a = 0,b = 0;
int now = 0;
for(int i = logn;i >= 0;i--)
if(Next[pos][i][now] && a + b + dis_a[pos][i][now] + dis_b[pos][i][now] <= x){
a += dis_a[pos][i][now];
b += dis_b[pos][i][now];
if(!i)
now ^= 1;
pos = Next[pos][i][now];
}
return make_pair(a,b);
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin >> n;
logn = log2(n) + 1;
for(int i = 1;i <= n;i++)
cin >> h[i];
h[0] = INF;h[n + 1] = -INF;
s.insert(make_pair(h[0],0));
s.insert(make_pair(h[0],0));
s.insert(make_pair(h[n + 1],n + 1));
s.insert(make_pair(h[n + 1],n + 1));
for(int i = n;i >= 1;i--){
s.insert(make_pair(h[i],i));
multiset<pair<int, int> >::iterator it = s.find(make_pair(h[i],i));
pair<int, int> pre,nex;
it--;
pre = make_pair((*it).first,(*it).second);
it++;it++;
nex = make_pair((*it).first,(*it).second);
it--;
if(abs(h[i] - pre.first) <= abs(h[i] - nex.first)){
Next[i][0][1] = pre.second;
it--;it--;
if(abs(h[i] - nex.first) <= abs(h[i] - (*it).first))
Next[i][0][0] = nex.second;
else
Next[i][0][0] = (*it).second;
it++;it++;
}
else{
Next[i][0][1] = nex.second;
it++;it++;
if(abs(h[i] - pre.first) <= abs(h[i] - (*it).first))
Next[i][0][0] = pre.second;
else
Next[i][0][0] = (*it).second;
it--;it--;
}
dis_a[i][0][0] = dist(i,Next[i][0][0]);
dis_b[i][0][1] = dist(i,Next[i][0][1]);
}
init();
cin >> x;
int ans1 = n + 1,ans2 = 0;
pair<int,int> Max = make_pair(1,0);
for(int i = 1;i <= n;i++){
pair<int,int> tmp = calc(i,x);
if(!tmp.second)
tmp.first = 1;
if(tmp.first * Max.second < tmp.second * Max.first || (tmp.first * Max.second == tmp.second * Max.first && h[i] > h[ans1])){
ans1 = i;
Max = tmp;
}
}
cout << ans1 << '\n';
cin >> q;
while(q--){
int st;
cin >> st >> x;
pair<int,int> tmp = calc(st,x);
cout << tmp.first << ' ' << tmp.second << '\n';
}
return 0;
}