EASY

5

2 votes
Easy
Problem

Given an array of N integers you have to calculate the value of sum of count[x]x where x represents the distinct elements of the array and count[x]is the number of times x occurs in the array.

Input

First line contains an integer n.

Second line contains an array of n integers where n<100000.

Output

A single integer denoting the answer.

Sample Input
3
1 2 2
Sample Output
5
Time Limit: 0.5
Memory Limit: 256
Source Limit:
Explanation

The answer is: count(2) * 2 +count(1) * 1 = 5.

Constraints:

1 A[i],N 100000

Editor Image

?