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

import java.util.Scanner;

public class Main {

	/**
	 * 入力された数のうち素数の数がいくつかを出力する
	 * 
	 * @param args
	 *            入力数、素数判定する数字
	 */
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();

		long check;
		int count = 0;// 素数の数
		// 入力された数の素数を判定する
		for (int i = 0; i < num; i++) {
			check = scan.nextLong();
			if (PrimeNumber_Checker(check)) {
				count++;
			}
		}
		System.out.println(count);
	}

	/**
	 * 素数であるかどうかを判定数
	 * 
	 * @param check_num
	 *            判定する数字
	 * @return 判定結果(true:素数)
	 */
	public static boolean PrimeNumber_Checker(long check_num) {
		if (check_num < 2) {// 1は素数ではない
			return false;
		}
		if (check_num == 2) {// ２は素数
			return true;
		}
		if (check_num % 2 == 0) {// 偶数は素数でない
			return false;
		}

		//素数判定では、「合成数xはp≦√xを満たす素因子pをもつ」という性質を利用することができます。
		//を適用
		double sqrtNum = Math.sqrt(check_num);
		for (int k = 3; k <= sqrtNum; k = k + 2) {
			if (check_num % k == 0) {
				return false;
			}
		}
		return true;

	}
}