#C4883. Sum of Unique Primes

    ID: 48470 Type: Default 1000ms 256MiB

Sum of Unique Primes

Sum of Unique Primes

You are given several test cases. For each test case, the input begins with a positive integer \(n\) which denotes the number of elements in the list. The following line contains \(n\) space-separated integers.

Your task is to identify the prime numbers in each list and compute the sum of the unique prime numbers. In other words, if a prime appears multiple times in the list, it should be counted only once.

For example, if the list is [7, 7, 7, 7, 7], the sum of unique primes is 7 because 7 is the only prime number present.

The formula for the sum is given by:

\[ S = \sum_{p \in P} p \] where \(P\) is the set of prime numbers in the list.

inputFormat

The first line of the input contains an integer \(T\) representing the number of test cases. For each test case, the input consists of two lines:

  • The first line contains a single integer \(n\) denoting the number of elements.
  • The second line contains \(n\) space-separated integers.

All input is read from standard input (stdin).

outputFormat

For each test case, output the sum of unique prime numbers in a single line. The outputs for different test cases should be printed in the order of the input. All output is to be written to standard output (stdout).

## sample
3
5
2 3 4 5 6
4
8 9 10 11
6
13 14 15 16 17 18
10

11 30

</p>