Please help me it is not accepting all tc

Try to solve this problem in the following way:

Run the loop through the length of the array. In each iteration insert the element it in set until there is no repeatition. Now calculate the sum of all possible length using formula n(n+1)/2 and add the sum to result.

it still not accepting all tc my code–>https://ide.codingblocks.com/s/246719