#include <bits/stdc++.h>
using namespace std;
int isPrime(long x);
int main() {
  long N, x;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> x;
    isPrime(x);
  }
  return 0;
}
int isPrime(long x) {
  bool prime;
  if (x == 1) {
    prime = false;
  } else if (x == 2) {
    prime = true;
  } else if ((x % 2) == 0) {
    prime = false;
  } else if ((x % 2) != 0) {
    for (int i = 3; i < x; i = i + 2) {
      if ((x % i) == 0) {
        prime = false;
        break;
      } else if (i >= sqrt(x)) {
        prime = true;
        break;
      }
    }
  }
  if (prime) {
    cout << x << endl;
  }
  return 0;
}
