#K69462. Sum of Unique Elements
Sum of Unique Elements
Sum of Unique Elements
Given several arrays, your task is to compute the sum of unique (distinct) elements for each array. In other words, if an element appears more than once in an array, it should be counted only once when calculating the sum.
For example, in the array [1, 2, 2, 3, 4], the unique elements are \(1, 2, 3,\) and \(4\), so the sum is \(1+2+3+4=10\).
Note: If you see any formula, it must be written in \(\LaTeX\) format.
inputFormat
The input begins with a single integer \(T\) denoting the number of test cases. Each test case is described as follows:
- The first line of a test case contains an integer \(n\) representing the number of elements in the array.
- The second line contains \(n\) space-separated integers.
outputFormat
For each test case, output a single line containing the sum of the unique elements of the corresponding array.
## sample3
5
1 2 2 3 4
4
1 1 1 1
6
5 5 5 5 5 5
10
1
5
</p>