AlgoUniversity
  • Go Back
Discussion
Minimizing Sum :

Author

Yash Sahijwani

Difficulty Level : Easy

Submissions : 435

Asked In : TCS

Marks :10

: 1 | : 0

Given an array $$$a$$$ consisting of $$$n$$$ non-negative integers, the following operation can be carried out any number of times:

  • Choose an index $$$i$$$ $$$(1 \leq i \leq n)$$$, and change $$$a_i$$$ to any non-negative integer $$$x$$$.
Note that $$$a_i$$$ should always be greater than or equal to its original value. After performing all operations, all the numbers in the array should be unique. Find the minimum possible sum of the elements of this array consisting of all unique numbers after performing all operations.

Input

The first line of input consists of an integer $$$n$$$ $$$-$$$ the total number of elements in the array. The second line consists of $$$n$$$ space separated integers - the elements of the array.

Output

Output a single integer - the minimum possible sum of the elements of the array after carrying out all operations.

Example

Input
3
2 2 4
Output
9

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.