#include <iostream>
using namespace std;
int main()
{
int x[100], n, y[100], nr=0, ok=0;
cin>>n;
for(int i=1;i<=n;i++)
cin>>x[i];
for(int i=n;i>=1;i--)
{
for(int j=1;j<=x[i];j++)
if(x[i]%j==0)
ok++;
if(ok==2)
{
nr=nr+1;
y[nr]=x[i];
}
ok=0;
}
for(int k=1;k<=nr;k++)
cout<<y[k]<<" ";
}