{ ll@n,@m,@p,x=1,y=0,z=0; rep(n){ll@a;while(a%p<1)a/=p;y>?=a;} if(y<2)wt(-1); else{ while(x