from math import gcd def f(x, y): if gcd(x, y) == 1: return (x - 1) * (y - 1) return 0 n = int(input()) a = list(map(int, input().split())) b = f(a[0], a[1]) k = [(1, 2)] if n == 2: pass elif n == 3: b = 10 ** 18 for x, y in zip([f(f(a[0], a[1]), a[2]), f(f(a[0], a[2]), a[1]), f(f(a[1], a[2]), a[0])], [[(1, 2), (1, 2)], [(1, 3), (1, 2)], [(2, 3), (1, 2)]]): if x >= b: continue b = x k = y else: b = 0 k = [(1, 2) for _ in [0] * (n - 1)] print(b) for x, y in k: print(x, y)