f=lambda x: 1 if x==2 or x==3 or (not x<2 and not x&1==0 and pow(2,x-1,x)==1) else 0

print((sum(f(int(eval(input()))) for _ in range(int(eval(input()))))))

f=lambda x: 1 if x == 2 or x == 3 or (x>3 and x&1==1 and pow(2, x-1, x)==1) else 0

print((sum(f(int(eval(input()))) for _ in range(int(eval(input()))))))

f = (
    lambda x: 1
    if x == 2 or x == 3 or (not x < 2 and not x & 1 == 0 and pow(2, x - 1, x) == 1)
    else 0
)
print((sum(f(int(eval(input()))) for _ in range(int(eval(input()))))))

f = (
    lambda x: 1
    if x == 2 or x == 3 or (x > 3 and x & 1 == 1 and pow(2, x - 1, x) == 1)
    else 0
)
print((sum(f(int(eval(input()))) for _ in range(int(eval(input()))))))

-    if x == 2 or x == 3 or (not x < 2 and not x & 1 == 0 and pow(2, x - 1, x) == 1) +    if x == 2 or x == 3 or (x > 3 and x & 1 == 1 and pow(2, x - 1, x) == 1)