priority_queue>q; ll a[2d5]; { ll@n,@m,@p; rd(a(n)); q.push({0,1}); while(!q.empty()){ pairt=q.top(); q.pop(); int k=-t.first; int x=t.second; if(x>m){ wt(k); exit(0); } if(k>=1000){ wt(-1); exit(0); } rep(i,n){ int y=x*a[i],z=k+1; while(y%p<1){ y/=p; ++z; } if(y>x){ q.push({-z,y}); } } } wt(-1); }