// competitive-verifier: PROBLEM https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/all/ALDS1_1_C
#include "../../../src/nt/is_prime/lib.hpp"
using namespace tifa_libs;
int main() {
std::cin.tie(nullptr)->std::ios::sync_with_stdio(false);
u32 t;
std::cin >> t;
u32 cnt = 0;
while (t--) {
u32 p;
std::cin >> p;
cnt += is_prime(p);
}
std::cout << cnt << '\n';
return 0;
}
#line 1 "test/cpv/aizu-alds1/alds1_1_c.cpp"
// competitive-verifier: PROBLEM https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/all/ALDS1_1_C
#line 2 "src/nt/is_prime/lib.hpp"
#line 2 "src/math/mul_mod/lib.hpp"
#line 2 "src/math/safe_mod/lib.hpp"
#line 2 "src/util/traits/math/lib.hpp"
// clang-format off
#line 2 "src/util/alias/num/lib.hpp"
#line 2 "src/util/util/lib.hpp"
// https://github.com/Tiphereth-A/CP-lib
#include <bits/extc++.h>
// clang-format off
namespace tifa_libs {
#define CEXP constexpr
#define CEXPE constexpr explicit
#define CR const&
#define CP const*
#define PC *const
#define CPC const*const
#define TPN typename
#define NE noexcept
#define CNE const noexcept
#define ND [[nodiscard]]
#define cT_(...) std::conditional_t<sizeof(__VA_ARGS__) <= sizeof(size_t) * 2, __VA_ARGS__, __VA_ARGS__ CR>
// NOLINTNEXTLINE(misc-const-correctness)
#define flt_(T, i, l, r, ...) for (T i = (l), i##e = (r)__VA_OPT__(, ) __VA_ARGS__; i < i##e; ++i)
#define retif_(cond, if_true, ...) if cond return if_true __VA_OPT__(; else return __VA_ARGS__)
#ifdef ONLINE_JUDGE
#undef assert
#define assert(x) 42
#endif
using namespace std::ranges;
using namespace std::literals;
template <class T>
CEXP T abs(T x) NE { retif_((x < 0), -x, x); }
} // namespace tifa_libs
// clang-format on
#line 4 "src/util/alias/num/lib.hpp"
// clang-format off
namespace tifa_libs {
#define mk0_(w, t) using w = t; using c##w = const t
#define mk_(w, t) mk0_(w, t); CEXP w operator""_##w(unsigned long long x) NE { return (w)x; }
mk_(i8, int8_t) mk_(u8, uint8_t) mk_(i16, int16_t) mk_(u16, uint16_t) mk_(i32, int32_t) mk_(u32, uint32_t) mk_(i64, int64_t) mk_(u64, uint64_t) mk_(isz, ssize_t) mk_(usz, size_t) mk_(chr, char) mk_(schr, signed char) mk_(uchr, unsigned char) mk_(sint, signed) mk_(uint, unsigned);
mk0_(i128, __int128_t); mk0_(u128, __uint128_t); mk0_(f32, float); mk0_(f64, double); mk0_(f128, long double);
#undef mk0_
#undef mk_
} // namespace tifa_libs
// clang-format on
#line 4 "src/util/traits/math/lib.hpp"
namespace tifa_libs {
template <class T> concept char_c = std::same_as<T, char> || std::same_as<T, signed char> || std::same_as<T, unsigned char>;
#pragma GCC diagnostic ignored "-Wpedantic"
template <class T> concept s128_c = std::same_as<T, __int128_t> || std::same_as<T, __int128>;
template <class T> concept u128_c = std::same_as<T, __uint128_t> || std::same_as<T, unsigned __int128>;
template <class T> concept i128_c = s128_c<T> || u128_c<T>;
#pragma GCC diagnostic warning "-Wpedantic"
template <class T> concept imost64_c = std::integral<T> && sizeof(T) * __CHAR_BIT__ <= 64;
template <class T> concept smost64_c = imost64_c<T> && std::signed_integral<T>;
template <class T> concept umost64_c = imost64_c<T> && std::unsigned_integral<T>;
template <class T> concept int_c = i128_c<T> || imost64_c<T>;
template <class T> concept sint_c = s128_c<T> || smost64_c<T>;
template <class T> concept uint_c = u128_c<T> || umost64_c<T>;
template <class T> concept arithm_c = std::is_arithmetic_v<T> || int_c<T>;
template <class T> concept mint_c = requires(T x) { {x.mod()} -> uint_c; {x.val()} -> uint_c; };
template <class T> concept dft_c = requires(T x, std::vector<TPN T::data_t> v, u32 n) { {x.size()} -> std::same_as<u32>; x.bzr(n); x.dif(v, n); x.dit(v, n); };
template <class T> concept ntt_c = dft_c<T> && requires(T x) { T::max_size; T::G; };
template <class T> struct to_sint : std::make_signed<T> {};
template <> struct to_sint<u128> { using type = i128; };
template <> struct to_sint<i128> { using type = i128; };
template <class T> using to_sint_t = TPN to_sint<T>::type;
template <class T> struct to_uint : std::make_unsigned<T> {};
template <> struct to_uint<u128> { using type = u128; };
template <> struct to_uint<i128> { using type = u128; };
template <class T> using to_uint_t = TPN to_uint<T>::type;
template <arithm_c T> struct to_bigger : std::make_unsigned<T> {};
#define _(w,ww) template <> struct to_bigger<w> { using type = ww; }
#define _2(w,ww) _(i##w,i##ww); _(u##w,u##ww);
_2(8, 16); _2(16, 32); _2(32, 64); _2(64, 128); _(f32, f64); _(f64, f128);
#undef _2
#undef _
template <class T> using to_bigger_t = TPN to_bigger<T>::type;
template <arithm_c T> CEXP T inf_v = [] {
if CEXP(sint_c<T>) return T(to_uint_t<T>(-1) / 4 - 1);
else if CEXP(uint_c<T>) return T(-1) / 2 - 1;
else return std::numeric_limits<T>::max() / 2 - 1;
}();
} // namespace tifa_libs
// clang-format on
#line 4 "src/math/safe_mod/lib.hpp"
namespace tifa_libs {
template <int_c T>
CEXP T safe_mod(T x, to_uint_t<T> mod) NE {
if CEXP (sint_c<T>) {
if (x <= -(T)mod || x >= (T)mod) x %= (T)mod;
retif_((x < 0), x + (T)mod, x);
} else {
retif_((x >= mod), x % mod, x);
}
}
} // namespace tifa_libs
#line 4 "src/math/mul_mod/lib.hpp"
namespace tifa_libs {
CEXP i64 mul_mod_s(i64 a, i64 b, u64 mod) NE {
if (std::bit_width((u64)abs(a)) + std::bit_width((u64)abs(b)) < 64) return safe_mod(a * b % (i64)mod, mod);
return safe_mod((i64)((i128)a * b % mod), mod);
}
CEXP u64 mul_mod_u(u64 a, u64 b, u64 mod) NE {
if (std::bit_width(a) + std::bit_width(b) <= 64) return a * b % mod;
return (u64)((u128)a * b % mod);
}
} // namespace tifa_libs
#line 2 "src/math/qpow/mod/lib.hpp"
#line 4 "src/math/qpow/mod/lib.hpp"
namespace tifa_libs {
CEXP u64 qpow_mod(u64 a, u64 b, u64 mod) NE {
u64 res(1);
for (a %= mod; b; b >>= 1, a = mul_mod_u(a, a, mod)) {
while (!(b & 1)) b >>= 1, a = mul_mod_u(a, a, mod);
res = mul_mod_u(res, a, mod);
}
return res;
}
} // namespace tifa_libs
#line 5 "src/nt/is_prime/lib.hpp"
namespace tifa_libs {
CEXP bool is_prime(u64 n) NE {
retif_((n <= 2) [[unlikely]], n == 2);
if (~n & 1) return false;
if (n < 8 || n == 61) return true;
if (!(n % 3) || !(n % 5) || !(n % 7)) return false;
if (n < 121) return true;
auto f = [n, d = (n - 1) >> std::countr_zero(n - 1)](auto&& bases) NE -> bool {
for (cu64 i : bases) {
if (!(i % n)) continue;
u64 t = d, y = qpow_mod(i, t, n);
while (t != n - 1 && y != 1 && y != n - 1) y = mul_mod_u(y, y, n), t *= 2;
if (y != n - 1 && (~t & 1)) return false;
}
return true;
};
// NOLINTBEGIN(modernize-avoid-c-arrays)
CEXP u64 THRES1 = 341531, BASE1[]{9345883071009581737u};
CEXP u64 THRES2 = 1050535501, BASE2[]{336781006125, 9639812373923155};
CEXP u64 THRES3 = 350269456337, BASE3[]{4230279247111683200, 14694767155120705706u, 16641139526367750375u};
CEXP u64 THRES4 = 55245642489451, BASE4[]{2, 141889084524735, 1199124725622454117, 11096072698276303650u};
CEXP u64 THRES5 = 7999252175582851, BASE5[]{2, 4130806001517, 149795463772692060, 186635894390467037, 3967304179347715805};
CEXP u64 THRES6 = 585226005592931977, BASE6[]{2, 123635709730000, 9233062284813009, 43835965440333360, 761179012939631437, 1263739024124850375};
CEXP u64 BASE7[]{2, 325, 9375, 28178, 450775, 9780504, 1795265022};
// NOLINTEND(modernize-avoid-c-arrays)
if (n < THRES1) return f(BASE1);
if (n < THRES2) return f(BASE2);
if (n < THRES3) return f(BASE3);
if (n < THRES4) return f(BASE4);
if (n < THRES5) return f(BASE5);
if (n < THRES6) return f(BASE6);
return f(BASE7);
}
} // namespace tifa_libs
#line 3 "test/cpv/aizu-alds1/alds1_1_c.cpp"
using namespace tifa_libs;
int main() {
std::cin.tie(nullptr)->std::ios::sync_with_stdio(false);
u32 t;
std::cin >> t;
u32 cnt = 0;
while (t--) {
u32 p;
std::cin >> p;
cnt += is_prime(p);
}
std::cout << cnt << '\n';
return 0;
}