#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
const int MAXN = 1e5 + 12;
const double EPS = 1e-5;
int n,m;
long long h[MAXN];
int f[MAXN],revf[MAXN];
int Ato[MAXN],Bto[MAXN];
inline long long jdz(long long x)
{
return (x<0)?-x:x;
}
bool cmp(int id1,int id2)
{
return h[id1] < h[id2];
}
int sd;
bool select(int a,int b)
{
if (jdz(h[a]-h[sd])==jdz(h[b]-h[sd])) return h[a]<h[b];
else return jdz(h[a]-h[sd])<jdz(h[b]-h[sd]);
}
void discret()
{
for (int i=1;i<=n;i++) revf[i] = i;
sort(revf+1,revf+n+1,cmp);
for (int i=1;i<=n;i++) f[revf[i]] = i;
}
struct treeNode
{
int l,r,sum;
}T[MAXN*8];
void add(int tar,int l,int r,int k)
{
if (l>tar||r<tar) return;
T[k].sum ++;
if (r<=l) return ;
int md = (l+r)>>1;
add(tar,l,md,k*2),add(tar,md+1,r,k*2+1);
}
int find(int tar,int l,int r,int k)
{
if (tar>T[k].sum||tar<=0) return -1;//Not find
if (l==r) return l;
int md = (l+r)>>1;
if (tar<=T[k*2].sum) return find(tar,l,md,k*2);
else return find(tar-T[k*2].sum,md+1,r,k*2+1);
}
int query(int tar,int l,int r,int k)
{
if (l==r) return 1;
int md = (l+r)>>1;
if (tar<=md) return query(tar,l,md,k*2);
else return T[k*2].sum + query(tar,md+1,r,k*2+1);
}
void addEdge()
{
for (int i=n;i>=1;i--)
{
add(f[i],1,n,1);
int id = query(f[i],1,n,1);
int x[6] = {},cnt=0;
x[0]=find(id-2,1,n,1),x[1]=find(id-1,1,n,1),x[2]=find(id+1,1,n,1),x[3]=find(id+2,1,n,1);
for (int j=0;j<=3;j++) if(x[j]!=-1) x[cnt++] = revf[x[j]];
sd = i;
sort(x,x+cnt,select);
x[cnt] = x[cnt+1] = 0;
Bto[i] = x[0],Ato[i] = x[1];
}
}
int jp[MAXN][23][2];
long long cntA[MAXN][23][2],cntB[MAXN][23][2]; // A->0 B->1
void makeSt()
{
for (int i=1;i<=n;i++) jp[i][0][0] = Ato[i],jp[i][0][1] = Bto[i],
cntA[i][0][0] = (Ato[i]==0)?0:jdz(h[Ato[i]]-h[i]),cntB[i][0][1] = (Bto[i]==0)?0:jdz(h[Bto[i]]-h[i]);
for (int i=1;i<=n;i++)
{
jp[i][1][0] = jp[jp[i][0][0]][0][1];
jp[i][1][1] = jp[jp[i][0][1]][0][0];
cntA[i][1][0] = cntA[i][0][0];
cntA[i][1][1] = cntA[jp[i][0][1]][0][0];
cntB[i][1][1] = cntB[i][0][1];
cntB[i][1][0] = cntB[jp[i][0][0]][0][1];
}
for (int k=2;(1<<k)<=n;k++)
{
for (int i=1;i<=n;i++)
{
jp[i][k][0] = jp[jp[i][k-1][0]][k-1][0];
jp[i][k][1] = jp[jp[i][k-1][1]][k-1][1];
cntA[i][k][0] = cntA[i][k-1][0] + cntA[jp[i][k-1][0]][k-1][0];
cntB[i][k][0] = cntB[i][k-1][0] + cntB[jp[i][k-1][0]][k-1][0];
cntA[i][k][1] = cntA[i][k-1][1] + cntA[jp[i][k-1][1]][k-1][1];
cntB[i][k][1] = cntB[i][k-1][1] + cntB[jp[i][k-1][1]][k-1][1];
}
}
}
void ask(int s,long long x,long long&A,long long&B)
{
for (int k=floor(log2(1.0*n));k>=0;k--)
{
if (cntA[s][k][0]+cntB[s][k][0]>x) continue;
x -= (cntA[s][k][0]+cntB[s][k][0]);
A += cntA[s][k][0],B += cntB[s][k][0];
s = jp[s][k][0];
}
}
void solve1()
{
long long x0,A,B;
int ans=n+1;
double res=1e18;
h[n+1] = -1e10;
scanf("%lld",&x0);
for (int i=1;i<=n;i++)
{
A = B = 0;
ask(i,x0,A,B);
double cur;
if (B==0) cur = 1e18;
else cur = 1.0*A/B;
if (cur-res>-EPS&&cur-res<EPS) ans = (h[i]>h[ans])?i:ans;
else if (cur<res) ans = i;
if (ans==i) res = cur;
}
printf("%d\n",ans);
}
void solve2()
{
int s;
long long x;
scanf("%d",&m);
while (m--)
{
scanf("%d%lld",&s,&x);
long long A=0,B=0;
ask(s,x,A,B);
printf("%lld %lld\n",A,B);
}
}
int main()
{
scanf("%d",&n);
for (int i=1;i<=n;i++) scanf("%lld",h+i);
discret();
addEdge();
makeSt();
solve1();
solve2();
return 0;
}