#include #include // url #define rep(i,a,b) for(int i=a;i=a;i--) #define all(x) (x).begin(),(x).end() #define pb(x) push_back(x); templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b P; int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); // int x,y;cin >> x >> y; // rep(z,1,x*y+1){ // int a=0; // cout << z << " "; // while(a*x<=z){ // int b=z-a*x; // if(b%y==0){ // cout << a << " " << b/y << endl; // break; // } // a++; // } // if(a*x>z){ // cout << -1 << " " << -1 << endl; // } // } Init(); fill(idx,idx+eratosSize,-1); int N;cin >> N; vector

A(N); int a=-1,b=-1; int one=-1; rep(i,0,N){ cin >> A[i].first; A[i].second=i; if(A[i].first<=1)one=i; if(a!=-1)continue; int tmp=A[i].first; while(tmp>1){ int p=eratos[tmp]; if(idx[p]==-1){ idx[p]=i; } else if(idx[p]!=i){ a=idx[p]; b=i; break; } while(tmp%p==0){ tmp/=p; } } } if(a!=-1){ cout << 0 << endl; cout << a+1 << " " << b+1 << endl; rrep(i,1,N-1){ cout << 1 << " " << i+1 << endl; } } else if(one!=-1){ cout << 0 << endl; cout << one+1 << " " << 1 << endl; rrep(i,1,N-1){ cout << 1 << " " << i+1 << endl; } } else if(idx[2]!=-1&&N>=3){ int x=-1,y=-1; rep(i,0,N){ if(A[i].first==2)continue; if(x==-1){ x=i; } else{ y=i; } } cout << 0 << endl; cout << x+1 << " " << y+1 << endl; int z=idx[2]; if(x=4){ cout << 0 << endl; cout << N-1 << " " << N << endl; cout << N-3 << " " << N-2 << endl; rrep(i,1,N-2){ cout << 1 << " " << i+1 << endl; } } else{ int x=-1,y=-1; ll X=inf,Y=inf; rep(j,0,N){ if(chmin(X,A[j].first)){ x=j; } } rep(j,0,N){ if(j==x)continue; if(chmin(Y,A[j].first)){ y=j; } } int w=3-x-y; ll z=(A[x].first-1)*(A[y].first-1); z=(z-1)*(A[w].first-1); cout << z << endl; cout << x+1 << " " << y+1 << endl; cout << 1 << " " << 2 << endl; } }