import sys, time, random from collections import deque, Counter, defaultdict 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 import itertools from math import gcd def f(x, y): if gcd(x, y) == 1: return x * y - x - y + 1 else: return 0 n = ii() a = li() ans = inf it = [] if n == 2: ans = f(a[0], a[1]) it = [(1, 2)] elif n == 3: for v in itertools.permutations(a): if ans >= f(f(v[0], v[1]), v[2]): one = a.index(v[0]) a[one] = -1 two = a.index(v[1]) a[one] = v[0] it = [(one + 1, two + 1), (1, 2)] ans = min(ans, f(f(v[0], v[1]), v[2])) else: ans = 0 it = [(1, 2) for _ in range(n - 1)] print(ans) for v in it: print(*v)