#include<cstdio>
#include<cstring>
#include<algorithm>
#define inf 2147483647
#define ld long double
#define ll long long
#define N 100010
using namespace std;
int n,m,x,sa,sb,hs,st,nx[N],ls[N],a[N],b[N],c[N],s[N],f[N][19];
ll pra[N][19],prb[N][19];
struct node{int v,id;}h[N];
ld ans=(ld)inf,t;
bool cmp(node x,node y){return x.v<y.v;}
int dis(int x,int y){return abs(h[x].v-h[y].v);}
void get(int x){
b[x]=(ls[x]&&(dis(x,ls[x])<=dis(x,nx[x])||!nx[x]))?ls[x]:nx[x];
if(b[x]==ls[x]){
a[x]=(ls[b[x]]&&(dis(x,ls[b[x]])<=dis(x,nx[x])||!nx[x]))?ls[b[x]]:nx[x];}
else{
a[x]=(ls[x]&&(dis(x,ls[x])<=dis(x,nx[b[x]])||!nx[b[x]]))?ls[x]:nx[b[x]];
}
nx[ls[x]]=nx[x];ls[nx[x]]=ls[x];
}
void work(int s,int x){
sa=sb=0;
for(int i=18;i>=0;i--){
if(x>=pra[s][i]+prb[s][i]){
x-=pra[s][i];x-=prb[s][i];
sa+=pra[s][i];sb+=prb[s][i];
s=f[s][i];
}
}
if(x>=pra[s][0]){x-=pra[s][0];sa+=pra[s][0];}
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&h[i].v),h[i].id=i,s[i]=h[i].v;
sort(h+1,h+1+n,cmp);
for(int i=1;i<=n;i++){c[h[i].id]=i;ls[i]=i-1;nx[i]=i+1;}
nx[n]=0;
for(int i=1;i<=n;i++) get(c[i]);
for(int i=1;i<=n;i++){
int x=c[i];
if(b[a[x]]&&a[x])prb[i][0]=abs(h[a[x]].v-h[b[a[x]]].v);
if(a[x]) pra[i][0]=abs(h[x].v-h[a[x]].v);
f[i][0]=h[b[a[x]]].id;
}
for(int j=1;j<=18;j++){
for(int i=1;i<=n;i++){
f[i][j]=f[f[i][j-1]][j-1];
pra[i][j]=pra[i][j-1]+pra[f[i][j-1]][j-1];
prb[i][j]=prb[i][j-1]+prb[f[i][j-1]][j-1];
}
}
scanf("%d",&x);
for(int i=1;i<=n;i++){
work(i,x);
if(!sb) continue;else t=(ld)sa/sb;
if(ans>t||(ans==t&&s[i]>s[hs])){ans=t;hs=i;}
}
printf("%d\n",hs);
scanf("%d",&m);
for(int i=1;i<=m;i++){
scanf("%d%d",&st,&x);
work(st,x);
printf("%d %d\n",sa,sb);
}
return 0;
}
11-02
6241
12-03
253
03-18
1009
08-30
348
10-15
524