#C2715. Sum of Primes
Sum of Primes
Sum of Primes
Given multiple datasets, each dataset contains a list of integers. For each dataset, compute the sum of prime numbers among the list. A number \(p\) is prime if it is greater than 1 and has no positive divisors other than 1 and itself. The input terminates when a dataset with 0 elements is encountered.
The mathematical condition for a number \(p\) to be prime is given by:
$$p > 1 \quad\text{and}\quad \forall q \ (1inputFormat
Standard input contains multiple test cases. Each test case starts with an integer (n) (where (n > 0)) which represents the number of elements. The next line contains (n) space-separated integers. The input ends when a test case with (n = 0) is encountered.
outputFormat
For each test case, output the sum of prime numbers, each on a separate line.## sample
5
2 3 4 5 6
3
-5 0 1
4
8 10 12 14
0
10
0
0
</p>