5
5 3
2 4
3 1
4 5
 4
2 4
3 2
2 1
 5
5 3
2 4
3 1
4 5
 2
1 2
 4
3 4
2 3
3 1
 10
8 10
2 9
7 8
4 1
7 3
4 7
2 5
2 4
4 6
 5
3 4
3 2
3 1
1 5
 3
1 2
2 3
 5
1 2
1 3
1 4
1 5

1 2
2 3
2 4
 1 3
2 4
3 5
4 5
 1 2
 1 3
2 3
3 4
 1 4
2 4
2 5
2 9
3 7
4 6
4 7
7 8
8 10
 1 3
1 5
2 3
3 4
 1 2
2 3
 1 2
1 3
1 4
1 5

import sys, os
from collections import defaultdict

# SCRIPT STARTS HERE
class sim:
    def __init__(self,edges,n):
        
        self.E=defaultdict(list)
        for u,v in edges:
            self.E[u]+=[v]
            self.E[v]+=[u]
        self.D=[[-1]*(n+1) for i in range(n+1)]
        for i in range(1,n+1):
            Q=[(i,0)]
            while Q:
                j,d=Q.pop()
                self.D[i][j]=d
                for v in self.E[j]:
                    if self.D[i][v]<0:
                        Q.append((v,d+1))
        #for i in range(1,n+1):
        #    for j in range(1,n+1):
        #        print(self.D[i][j],end='')
        #    print()
        
        
    def query(self,index):
        print('?',index+1)
        return self.D[index]
    
if os.environ['USERNAME']=='kissz':
    #n=4
    #simulator=sim([(4,2),(1,2),(2,3)],n) 
    #n=5
    #simulator=sim([(4,5),(3,5),(2,4),(1,3)],n)
    n=8
    simulator=sim([(1,2),(1,8),(8,3),(7,8),(6,7),(4,6),(5,6)],8)
    inp=simulator.query
    def debug(*args):
        print(*args,file=sys.stderr)
else:
    n=int(input())
    def inp(index):
        print('?',index+1)
        sys.stdout.flush()
        return [-1]+[*map(int,input().split())]
    def debug(*args):
        pass    

L=inp(1)
par=[(-1,-1,-1)]+[(d,1,i+1) for i,d in enumerate(L[1:])]

while 1:
#for _ in range(2):
    #print(par)
    d,p,j=max(par)
    if d==1:
        break
    else:
        X=inp(j)
        lj=L[j]
        F=[-1]*(lj+1)
        for i in range(1,n+1):
            dij=X[i]
            li=L[i]
            if li+dij==lj:
                F[dij]=i # self inc.
        #print(F)
        for i in range(d):
            par[F[i]]=(1,F[i+1],F[i])
        for i in range(1,n+1):
            dij=X[i]
            li=L[i]
            xj=(dij+lj-li)//2
            xi=dij-xj
            if 0<xi<par[i][0]:
                par[i]=(xi,F[xj],i)
        
print('!')
for _,p,j in par[2:]:
    print(j,p)
    


