import sys from math import gcd from itertools import permutations 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 = 10 ** 18 ops = [] if(n == 2): ans = f(a[0], a[1]) ops = [(1, 2)] elif(n == 3): ans = f(f(a[0], a[1]), a[2]) ops = [(1, 2), (1, 2)] t = f(f(a[0], a[2]), a[1]) if(t < ans): ans = t ops = [(1, 3), (1, 2)] t = f(f(a[1], a[2]), a[0]) if(t < ans): ans = t ops = [(2, 3), (1, 2)] else: ans = 0 ops = [(1, 2), (1, 2), (n - 3, n - 2)] for i in range(n - 3, 1, -1): ops.append((1, i)) print(ans) for x, y in ops: print(x, y)