use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::cmp::*;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(std::io::stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.read()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn is_prime(n: u32) -> bool {
    if n <= 1 {
        return false;
    }
    for i in 2..n {
        if i * i > n {
            break;
        }
        if n % i == 0 {
            return false;
        }
    }
    true
}

fn is_prime_table(n: usize) -> Vec<bool> {
    let mut is_prime = vec![true; n + 1];
    is_prime[0] = false;
    is_prime[1] = false;
    for i in 2..n+1 {
        unsafe {
            if *is_prime.get_unchecked(i) {
                let mut j = i * i;
                while j <= n {
                    *is_prime.get_unchecked_mut(j) = false;
                    j += i;
                }
            }
        }
    }
    is_prime
}

fn prime_table(n: usize) -> Vec<u64> {
    let is_prime = is_prime_table(n);
    is_prime.iter().enumerate()
        .filter(|&(_, &isp)| isp).map(|(i, _)| i as u64)
        .collect()
}

fn is_prime_mr(n: u64, ws: &[u64]) -> bool {
    fn modpow(a: u64, b: u64, n: u64) -> u64 {
        let mut a = a;
        let mut b = b;
        let mut res = 1;
        while b != 0 {
            if b & 1 != 0 {
                res = res * a % n;
            }
            a = a * a % n;
            b /= 2;
        }
        res
    }

    fn suspect(a: u64, mut t: u64, n: u64) -> bool {
        let mut a = modpow(a, t, n);
        while t != n - 1 && a != 1 && a != n - 1 {
            a = a * a % n;
            t = t * 2 % n;
        }
        a == n - 1 || t % 2 == 1
    }

    if n == 2 {
        true
    } else if n < 2 || n % 2 == 0 {
        false
    } else {
        let m = n - 1;
        let d = m / (m & m.wrapping_neg());
        ws.iter().all(|&w| w % n == 0 || suspect(w, d, n))
    }
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let ws = [2, 7, 61];

    // for i in 1..20 {
    //     println!("{} {}", i, is_prime_mr(i, &ws));
    // }

    let n = sc.read();
    let mut cnt = 0;
    for _ in 0..n {
        let x = sc.read();
        if is_prime_mr(x, &ws) {
            cnt += 1;
        }
    }
    println!("{}", cnt);

    // println!("{:?}", prime_table(10));
    
    // let is_prime = is_prime_table(100_000_000);
    // println!("{:?}", &is_prime[0..20]);
    // let n = sc.read();
    // let mut cnt = 0;
    // for _ in 0..n {
    //     let x: usize = sc.read();
    //     if is_prime[x] {
    //         cnt += 1;
    //     }
    // }
    // println!("{}", cnt);
}



Measured memory_bytes: 9076