Problem:
Prime Numbers

A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.

Write a program which reads a list of N integers and prints the number of prime numbers in the list.

Input

The first line contains an integer N, the number of elements in the list.

N numbers are given in the following lines.

Output

Print the number of prime numbers in the given list.

Constraints

1 ≤ N ≤ 10000

2 ≤ an element of the list ≤ 108

Sample Input 1

5
2
3
4
5
6

Sample Output 1

3

Sample Input 2

11
7
8
9
10
11
12
13
14
15
16
17

Sample Output 2

4

Solution in Rust (judge verdict: Accepted)

use std::io::BufRead;
use std::str::FromStr;
use std::fmt::Debug;

struct Scanner<R: BufRead> {
    buf_reader: R,
}

impl<R: BufRead> Scanner<R> {
    fn new(buf_reader: R) -> Self {
        Scanner {buf_reader: buf_reader}
    }
    fn read_line<T>(&mut self) -> Vec<T> where T: FromStr, <T as FromStr>::Err: Debug {
        let mut line = String::new();
        self.buf_reader.read_line(&mut line).unwrap();
        line.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
    }
    fn read_single_value<T>(&mut self) -> T where T: FromStr, <T as FromStr>::Err: Debug {
        let mut line = String::new();
        self.buf_reader.read_line(&mut line).unwrap();
        let sv: Vec<&str> = line.trim().split_whitespace().collect();
        sv[0].parse::<T>().unwrap()
    }
    fn read_line0(&mut self) -> Vec<String> {
        let mut line: String = String::new();
        self.buf_reader.read_line(&mut line).unwrap();
        line.trim().split_whitespace().map(|c| c.to_string()).collect()
    }
}

fn gcd(x: u32, y: u32) -> u32 {
    if x < y {
        gcd(y, x)
    }
    else if x % y == 0 {
        y
    }
    else {
        gcd(y, x%y)
    }
}

fn is_prime(p: u32) -> bool {
    if p <= 1 {
        return false;
    } else if p <= 3 {
        return true;
    }

    let mut q: u32 = ((p as f64).sqrt() + 1.0) as u32;
    while q > 1 {
        if gcd(p, q) != 1 {
            return false;
        }
        q -= 1;
    }
    true
}

fn main() {
    let stdin = std::io::stdin();
    let mut scanner = Scanner::new(stdin.lock());
    let n = scanner.read_single_value::<u32>();
    let mut cnt = 0;
    for i in 0..n {
        let p = scanner.read_single_value::<u32>();
        if is_prime(p) {
            cnt += 1;
        }
    } 
    println!("{}", cnt);
}