#C9705. Sum of Unique Elements

    ID: 53828 Type: Default 1000ms 256MiB

Sum of Unique Elements

Sum of Unique Elements

You are given an array of integers. Your task is to compute the sum of unique elements in the array. In other words, if an element appears multiple times in the array, consider it only once in the sum.

Formally, let \(S\) be the set of elements in the array \(A = [a_1, a_2, \dots, a_n]\). You need to compute:

[ \text{result} = \sum_{x \in S} x ]

The input consists of multiple test cases. For each test case, the first number denotes the number of elements in the array, followed by the list of integers. Your program should output the sum of unique elements for each test case on a new line.

inputFormat

The input begins with an integer \(T\) denoting the number of test cases. Each test case consists of:

  1. An integer \(n\) representing the number of elements in the array.
  2. A line containing \(n\) space-separated integers.

The input should be read from standard input (stdin).

outputFormat

For each test case, output a single line containing the sum of the unique elements of the array. The output should be written to standard output (stdout).

## sample
5
7
1 2 3 2 4 5 1
5
7 7 8 9 9
5
1 2 3 4 5
5
-1 -2 -3 -4 -5
1
10
15

24 15 -15 10

</p>