#include <bits/stdc++.h>
int check(long long int num) {
  int i, j, index = 0;
  for (j = 2; j * j <= num; j++) {
    if (num % j == 0) index = 1;
  }
  if (index == 0) printf("%lld\n", num);
  return 0;
}
int main() {
  int size, i;
  scanf("%d", &size);
  long long int arr[size];
  for (i = 0; i < size; i++) {
    scanf("%lld", &arr[i]);
    check(arr[i]);
  }
  return 0;
}
