#K68307. Sum of Primes in an Array

    ID: 32835 Type: Default 1000ms 256MiB

Sum of Primes in an Array

Sum of Primes in an Array

Given a list of integers, compute the sum of all prime numbers in the list. A prime number is defined as a number greater than 1 that has no divisors other than 1 and itself. You are required to read the input from stdin and output the result to stdout.

Input Format:

  • The first line contains an integer n, the number of elements in the array.
  • The second line contains n space-separated integers.

Output Format:

  • A single integer representing the sum of all prime numbers present in the array.

Note: Negative numbers, 0 and 1 are not considered prime.

inputFormat

The input consists of two lines:

  1. Line 1: An integer n, the number of elements.
  2. Line 2: n space-separated integers representing the elements of the array.

outputFormat

Output a single integer: the sum of all prime numbers in the array.

## sample
10
1 2 3 4 5 6 7 8 9 10
17

</p>