#include <iostream>
using namespace std;
int i,n,v[101];
int prim(int x)
{
int d;
if (x==1)
return 0;
for (d=2;d<=n/2;d++)
if (x%d==0)
return 0;
return 1;
}
int main()
{
cin>>n;
for (i=1;i<=n;i++)
{
cin>>v[i];
if (prim(v[i]))
v[i]=0;
}
for (i=1;i<=n;i++)
cout<<v[i]<<" ";
}