#K13146. Sum of Unique Elements

    ID: 23848 Type: Default 1000ms 256MiB

Sum of Unique Elements

Sum of Unique Elements

Given an array of integers, your task is to compute the sum of all unique elements in the array. In other words, if an element appears multiple times, it is only considered once in the sum. Mathematically, the answer is given by:

$$S = \sum_{x \in U} x$$

where U is the set of distinct elements in the array.

inputFormat

The input begins with an integer T, the number of test cases. For each test case, the first line contains an integer N denoting the number of elements in the array. The second line contains N space-separated integers representing the array elements.

outputFormat

For each test case, output a single line containing one integer: the sum of the unique elements in the array.## sample

1
5
1 2 2 3 4
10

</p>