import math N=int(input()) A=list(map(int,input().split())) def f(x,y): if math.gcd(x,y)==1: return (x-1)*(y-1) return 0 if N==2: M=f(A[0],A[1]) print(M) print(1,2) exit() if N==3: ans1=(f(A[2],f(A[0],A[1])),(1,2),(1,2)) ans2=(f(A[0],f(A[1],A[2])),(2,3),(1,2)) ans3=(f(A[1],f(A[0],A[2])),(1,3),(1,2)) ans=min(ans1,ans2,ans3) print(ans[0]) print(*ans[1]) print(*ans[2]) exit() print(0) print(1,2) print(1,2) print(N-3,N-2) for i in range(N-3,1,-1): print(1,i)