import math n = int(input()) A = list(map(int,input().split())) if 1 in A: print(1) f = A.index(1) + 1 s = 2 if f == 1 else 1 print(f,s) for i in range(n-2): print(n-2-i,1) exit() if 0 in A: print(0) f = A.index(0) + 1 s = 2 if f == 1 else 1 print(f,s) for i in range(n-2): print(n-2-i,1) exit() dic = {} target = [] for i,a in enumerate(A,1): now = a for j in range(2,int(a**0.5)+1): if now%j: continue if j in dic: target = [i,dic[j]] break while now % j == 0: now //= j dic[j] = i if now == 1: continue j = now if j in dic: target = [i,dic[j]] break dic[j] = i if target: print(0) print(*target) for i in range(n-2): print(1,n-2-i) exit() even = [] odd = [] for i,a in enumerate(A,1): if a%2: odd.append(i) else: even.append(i) def get(A): ans = (A[0]-1) * (A[1]-1) for i in range(2,n): ans = (ans-1)*(A[i]-1) return ans if (n == 3 and even == []) or n == 2: print(get(A)) for i in range(n-1): print(1,2) exit() print(0) assert len(even) < 2 if even: f = odd.pop() s = odd.pop() print(f,s) x = even[0] if x > f: x -= 1 if x > s: x -= 1 print(x,n-2) for i in range(n-3): print(1,n-3-i) else: print(1,2) print(1,2) print(n-2,n-3) for i in range(n-4): print(1,n-4-i)