import sys input = sys.stdin.readline n = int(input()) a = list(map(int, input().split())) x = 0 for ai in a: x ^= ai t = 1 if x!=0 else 0 print(t) turn = 0 while True: if turn^t: for i in range(n): if a[i]>x^a[i]: k = a[i]-(x^a[i]) print(i+1, k) sys.stdout.flush() x ^= a[i] a[i] -= k x ^= a[i] break else: i, k = map(int, input().split()) x ^= a[i-1] a[i-1] -= k x ^= a[i-1] ret = int(input()) if ret==-1: exit() turn ^= 1