BETA

Difficulty Level: Basic

Submissions: 952 Accuracy:

46.53%

Sum of distinct elements for a limited range
     

Given an array of n elements such that every element of array is an integer in the range 1 to n, find the sum of all the distinct elements of the array.

Input:
First line consists of T test cases. First line of every test case consists of N. Second line of every test case consists of elements of Array.

Output:
Single line output, print the sum of distinct element of array.

Constraints:
1<=T<=200
1<=N<=10^4

Example:
Input:

2
5
1 2 3 3 4
5
1 1 1 2 2
Output:
10
3

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Raj Seth

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.