import scala.io.StdIn.readInt
import scala.collection.immutable.TreeSet
import scala.annotation.tailrec
object Main {
    def main(args: Array[String]) {
        val len = readInt
        val nums = (1 to len).foldLeft(TreeSet(): TreeSet[Int]) {(a, b) => a + readInt}
        val pNums = primes(nums.last)
        println(nums.foldLeft(0) { (a, b) => if (inArray(b, pNums)) a + 1 else a})
    }
    def inArray(n: Int, arr: Array[Int]): Boolean = {
        @tailrec
        def inArray1(n1: Int, first: Int, last: Int, arr1:Array[Int]): Boolean = ((first + last) / 2) match {
            case a: Int if n1 == arr(a) => true
            case a: Int if first == last => false
            case a: Int if n1 < arr(a) => inArray1(n1, first, a, arr1)
            case a: Int if n1 > arr(a) => inArray1(n1, a + 1, last, arr1)
        }
        inArray1(n, 0, arr.length - 1, arr)
    }
    def primes(num: Int): Array[Int] = {
        def check(v: Int, primes: Array[Int]): Boolean = {
            primes.foreach(i => if (v % i == 0) return false)
            true
        }
        @tailrec
        def primes1(n: Int, curr: Int, parr: Array[Int]): Array[Int] = curr match {
            case a: Int if a > n => parr
            case a: Int if !check(a, parr)=> primes1(n, a + 1, parr)
            case a: Int => primes1(n, a + 1, parr :+ a)
        }
        primes1(num, 2, Array())
    }

}
