import math
def isPrime(n): # 1质数 0不是质数
m = math.ceil(math.sqrt(n))
if n<=1:
return 0
elif n==2:
return 1
else:
for i in range(2, m+1):
if n%i == 0: #整除 非质数
return 0
return 1
n = int(input())
line = input()
num_list = list(map(int, line.split(' '))) # input numbers
ans_list = [] # store the prime numbers
for i in range(n):
if isPrime(num_list[i]):
ans_list.append(num_list[i])
print(*ans_list, sep = ' ')