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 OCaml (judge verdict: Accepted)

type intseq = Cons of int * (int -> intseq) ;; (* 整数の無限列 *)

let rec is_divisible lst x = (* リストのいずれかの要素でxが割り切れるかどうかチェックする. *)
  let max = float_of_int x |> sqrt |> int_of_float in (* チェックする最大値 *)
  match lst with
    [] -> false 
  | p::ps when p > max -> false
  | p::ps -> if x mod p = 0 then true
             else is_divisible ps x ;;

let rec prime_seq primes x =    (* 素数の無限列. primesはアキュムレータであり, 素数のリスト *)
  if is_divisible primes (x+1) then prime_seq primes (x+1)
  else Cons(x+1, prime_seq (primes @ [x+1])) ;;

let is_prime x =                (* xが素数かどうかチェックする *)
  let max = float_of_int x |> sqrt |> int_of_float in
  let rec is_p p_seq =            (* xが素数の数列で割り切れるかチェックする *)
    let Cons(n, f) = p_seq in
    if n > max then true
    else if x mod n = 0 then false
    else is_p (f n)
  in
  is_p (prime_seq [] 1) ;;

let () =
  let open Scanf in
  let m = scanf "%d\n" (fun x -> x) in
  let as_ = Array.init m (fun _ -> scanf "%d\n" (fun x -> if is_prime x then 1 else 0)) in
  Array.fold_left (+) 0 as_
  |> Printf.printf "%d\n" ;;