#K39642. Sum of Primes
Sum of Primes
Sum of Primes
Given a list of non-negative integers, your task is to compute the sum of all prime numbers in the list. A number \( p \) is a prime if and only if \( p > 1 \) and it has no divisors other than 1 and itself.
The input is read from stdin
and the output should be written to stdout
. The first line of input contains a single integer \( n \) representing the number of elements in the list. The second line contains \( n \) space-separated non-negative integers.
Your solution must correctly identify prime numbers and compute their sum. For example, given the input:
5 3 11 4 6 8The correct output is
14
because 3 and 11 are the only primes in the list.
inputFormat
The first line contains an integer \( n \) denoting the number of elements. The second line contains \( n \) space-separated non-negative integers.
outputFormat
Output a single integer representing the sum of all prime numbers in the list.
## sample5
3 11 4 6 8
14