#K96377. Max Prime Subsequence Sum
Max Prime Subsequence Sum
Max Prime Subsequence Sum
You are given several datasets. Each dataset starts with an integer \(n\) followed by a line of \(n\) space-separated integers. Your task is to compute the sum of all prime numbers in the dataset.
A prime number is defined as a positive integer greater than 1 that has no positive divisors other than 1 and itself. Formally, a number \(p\) is prime if \(p > 1\) and for every integer \(d\) such that \(1 < d < p\), \(d\) does not divide \(p\). If there are no prime numbers in a dataset, output NONE
.
The input terminates with a dataset that starts with \(0\), which should not be processed.
inputFormat
The input consists of multiple datasets. For each dataset:
- The first line contains an integer \(n\) (\(1 \le n \le 10^5\)), representing the number of integers in the dataset.
- The second line contains \(n\) space-separated integers.
The last dataset is followed by a line containing a single \(0\), which terminates the input.
outputFormat
For each dataset, output the sum of the prime numbers found in that dataset. If there is no prime number, output NONE
. Each result should be printed on its own line.
5
2 3 6 7 11
6
4 6 8 9 10 15
8
-11 7 -5 3 -2 5 1 11
1
15
0
23
NONE
26
NONE
</p>