#include <bits/stdc++.h>
int main() {
  int n, i, a, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a);
    for (j = 2; j <= a / 2; j++)
      if (a % j == 0) break;
    if (j == (a / 2) + 1) printf("%d\n", a);
  }
  return 0;
}
