import sys from math import gcd input = sys.stdin.readline 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())) ans = f(a[0], a[1]) ops = [(1, 2)] if(n == 2): pass elif(n == 3): ans_lis = [f(f(a[0], a[1]), a[2]), f(f(a[0], a[2]), a[1]), f(f(a[1], a[2]), a[0])] op_lis = [[(1, 2), (1, 2)], [(1, 3), (1, 2)], [(2, 3), (1, 2)]] ans = 10 ** 18 for x, y in zip(ans_lis, op_lis): if(x >= ans): continue ans = x ops = y else: ans = 0 ops = [(1, 2) for _ in [0] * (n - 1)] print(ans) for x, y in ops: print(x, y)