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

#include <stdio.h>
#include <math.h>

//問題文より、入力されるデータの最大個数
#define MAXCOUNT 10000

//素数であるか確認する関数
int check_prime(int number);

int main(void)
{
	//nは入力されるデータの個数を、countは素数の個数を格納
	int i, n, count;
	int number[MAXCOUNT];

	scanf("%d", &n);

	//n個のデータを入力
	for(i = 0; i < n; i++){
		scanf("%d", &number[i]);
	}

	count = 0;
	//入力されたデータ分、素数であるか判定する
	for(i = 0; i < n; i++){
		if(check_prime(number[i])){
			count++;
		}
	}

	//結果を出力
	printf("%d\n", count);

	return 0;
}

//返り値が1ならば素数であり、0ならば素数でない
int check_prime(int number)
{
	//flagが1ならば素数
	int i, sqrt_number;
	int flag;

	//2～√numberまでの数で割り切れるか確認する
	sqrt_number = sqrt(number);

	flag = 1;
	for(i = 2; i <= sqrt_number; i++){
		//割り切れた場合は素数でない
		if(!(number % i)){
			flag = 0;
			break;
		}
	}

	return flag;
}