#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> x;
    int cnt = 2;
    while (cnt != x) {
      if (x % cnt == 0) {
        break;
      }
      cnt++;
    }
    if (cnt == x) {
      cout << x << endl;
    }
  }
}
