#C12060. Sum of Primes in an Array

    ID: 41446 Type: Default 1000ms 256MiB

Sum of Primes in an Array

Sum of Primes in an Array

Given a list of integers, your task is to calculate and output the sum of all prime numbers present in the list. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. In mathematical terms, a prime number \( p \) satisfies:

[ p > 1 \quad\text{and}\quad \nexists ; d \in \mathbb{N}\setminus{1, p} ; \text{such that} ; d \mid p ]

The input is given via standard input (stdin), where the first line contains an integer \( n \) representing the number of elements in the array. The next line contains \( n \) space-separated integers. Your program should output the sum of all prime numbers found in the array via standard output (stdout).

inputFormat

The first line contains a single integer \( n \) (\(0 \leq n \leq 10^5\)), representing the number of integers. The second line contains \( n \) space-separated integers. Each integer \( a_i \) satisfies \(-10^9 \leq a_i \leq 10^9\).

outputFormat

Output a single integer which is the sum of all prime numbers in the given array. If there are no primes, output 0.

## sample
7
10 15 3 7 19 21 29
58