#C8320. Sum of Primes Challenge
Sum of Primes Challenge
Sum of Primes Challenge
Given an array of integers, your task is to calculate the sum of all the prime numbers present in the array.
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. In this problem, you will first need to determine if a number is prime using the definition below:
$$ \text{A number } n \text{ is prime if } n > 1 \text{ and for all } a \in \mathbb{N},\, 2 \leq a \leq \sqrt{n}, \; a \nmid n. $$
You are required to read the input from the standard input (stdin) and print the result to the standard output (stdout).
Input Format: The first line contains an integer n, representing the number of elements in the array. The second line contains n space-separated integers.
Output Format: Output a single integer representing the sum of all prime numbers in the array.
inputFormat
The input consists of two lines. The first line contains a single integer n (the number of elements in the array). The second line contains n space-separated integers.
outputFormat
Output a single integer which is the sum of all prime numbers in the array.
## sample5
2 3 4 5 6
10