#include <iostream>
#include <fstream>
using namespace std;
ofstream out ("DATE.OUT");
int main()
{
int x, prim;
cin>>x;
if ( x != 0 )
{
while ( x != 0 )
{
cin >> x;
if ( x == 2 )
out<<x<<endl;
else
if( x % 2 != 0 )
{
for(int d=2;d<=x/2;d++)
if(x%d==0)
prim++;
if(prim==0)
out<<x<<endl;
}
}
}
}