#include<bits/stdc++.h>
using namespace std;
int flag = 0;
void work(int x){
for(int i = 2;i <= x;++i){
if(x % i == 0){
flag = 1;
}
}
if(flag == 0){
cout << x << " ";
}
}
int main(){
int n;
cin >> n;
for(int i = 1;i <= n;++i){
int x;
cin >> x;
work(x);
}
return 0;
}