import sys from collections import defaultdict, deque, Counter sys.setrecursionlimit(5 * 10 ** 5) from pypyjit import set_param set_param('max_unroll_recursion=-1') input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 n = ii() a = li() class segtree(): n=1 size=1 log=2 d=[0] op=None e=10**15 def __init__(self,V,OP,E): self.n=len(V) self.op=OP self.e=E self.log=(self.n-1).bit_length() self.size=1<>i) def get(self,p): assert 0<=p and p>=1 r>>=1 return self.op(sml,smr) def all_prod(self): return self.d[1] def update(self,k): self.d[k]=self.op(self.d[2*k],self.d[2*k+1]) def __str__(self): return str([self.get(i) for i in range(self.n)]) xor = 0 di = {} for i in range(n): if a[i] not in di: di[a[i]] = set([i]) di[a[i]].add(i) for v in a: xor ^= v a = segtree(a, max, -inf) def oppo(): global xor i, k = mi() i -= 1 if a[i] not in di: raise Exception di[a[i]].discard(i) xor ^= a[i] a[i] -= k xor ^= a[i] if a[i] not in di: di[a[i]] = set([i]) di[a[i]].add(i) def me(): global xor i = di[a.all_prod()].pop() k = xor xor = 0 a[i] -= k print(i + 1, k, flush=True) if a[i] not in di: di[a[i]] = set([i]) di[a[i]].add(i) if xor == 0: print(0, flush=True) oppo() else: print(1, flush=True) while True: me() r = ii() if r == -1: exit() oppo() r = ii() if r == -1: exit()