from math import gcd def f(a, b): if gcd(a, b) == 1: return a * b - a - b + 1 else: return 0 n = int(input()) A = list(map(int, input().split())) odd = [] even = [] for i, a in enumerate(A): if a % 2 == 1: odd.append(i) else: even.append(i) if len(even) >= 2: i, j = even[:2] print(0) print(i + 1, j + 1) for i in range(n - 2, 0, -1): print(i, i + 1) elif even and len(odd) >= 2: i, j = odd[:2] print(0) print(i + 1, j + 1) ii = even[0] if i < ii: ii -= 1 if j < ii: ii -= 1 print(ii + 1, n - 1) for i in range(n - 3, 0, -1): print(i, i + 1) elif len(odd) >= 4: i, j, k, l = odd[:4] print(0) print(k + 1, l + 1) print(i + 1, j + 1) print(n - 3, n - 2) for i in range(n - 4, 0, -1): print(i, i + 1) elif n == 2: a, b = A print(f(a, b)) print(1, 2) else: assert n == 3 a, b, c = A mi1 = f(f(a, b), c) mi2 = f(f(a, c), b) mi3 = f(f(b, c), a) mi = min(mi1, mi2, mi3) print(mi1) if mi == mi1: print(1, 2) elif mi == mi2: print(1, 3) else: print(2, 3) print(1, 2)