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)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;

namespace Prime_Numbers
{
    class Program
    {
        
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int ans = 0;
            int work;
            for (int i = 0; i < n; ++i)
            {
                work = int.Parse(Console.ReadLine());
                if (My_Algorithm.Is_Prime(work))
                {
                    ++ans;
                }
            }
            Console.WriteLine(ans);
        }
    }

    public static class My_Algorithm
    {
        //?????\????????? Insertion_Sort
        public static void Insertion_Sort(ref int[] array)
        {
            for (int i = 1; i < array.Length; ++i)
            {
                int v = array[i];
                int j = i - 1;
                while (j >= 0 && array[j] > v)
                {
                    array[j + 1] = array[j];
                    --j;
                }
                array[j + 1] = v;
                //for (int k = 0; k < array.Length - 1; ++k) Console.Write("{0} ", array[k]);
                //Console.WriteLine(array[array.Length - 1]);
            }
        }

        //?????§??¬?´???° Greatest_Common_Divisor
        public static int GCD(int m, int n)
        {
            if ((m == 0) || (n == 0)) return 0;
            while ((m != 0) && (n != 0))
            {
                if (m > n) m = m % n;
                else n = n % m;
            }
            if (m == 0) return n;
            else return m;
        }
        public static long GCD(long m, long n)
        {
            if ((m == 0) || (n == 0)) return 0;
            while ((m != 0) && (n != 0))
            {
                if (m > n) m = m % n;
                else n = n % m;
            }
            if (m == 0) return n;
            else return m;
        }
        //????°???¬?????° Least_Common_Multiple
        public static int LCM(int m, int n)
        {
            if ((m == 0) || (n == 0)) return 0;
            return m * n / My_Algorithm.GCD(m, n);
        }
        public static long LCM(long m, long n)
        {
            if ((m == 0) || (n == 0)) return 0;
            return m * n / My_Algorithm.GCD(m, n);
        }
        
        //??¨???????????????????????? Eratosthenes's_Sieve
        public static List<int> Prime_Number_List(int n)
        {
            bool k;
            List<int> list = new List<int>();
            list.Add(2);
            for (int i = 3; i <= n; i += 2)
            {
                k = true;
                for (int j = 3; j * j <= i; j += 2)
                {
                    if (i % j == 0)
                    {
                        k = false;
                        break;
                    }
                }
                if (k) list.Add(i);
            }
            return list;
        }
        public static List<long> Prime_Number_List(long n)
        {
            bool k;
            List<long> list = new List<long>();
            list.Add(2);
            for (int i = 3; i <= n; i += 2)
            {
                k = true;
                for(int j = 3;j * j <= i; j+=2)
                {
                    if (i % j == 0)
                    {
                        k = false;
                        break;
                    }
                }
                if (k) list.Add(i);
            }
            return list;
        }

        //?´???°???????????? Is_Prime?
        public static bool Is_Prime(int n)
        {
            if (n < 1) return false;
            if (n == 2) return true;
            if (n % 2 == 0) return false;
            for (int i = 3; i * i <= n; i += 2)
            {
                if (n % i == 0) return false;
            }
            return true;
        }
        public static bool Is_Prime(long n)
        {
            if (n < 1) return false;
            if (n == 2) return true;
            if (n % 2 == 0) return false;
            for (long i = 3; i * i <= n; i += 2)
            {
                if (n % i == 0) return false;
            }
            return true;
        }
    }

}