cswork / OA打开练习工作台

AmazonOA #369

Compute Maximum Earning Points

估计中等可在线判题

考点(AI 标注)贪心调度

Each item can be bought at most once. Buying an item earns its current points, after which the points of every other unbought item decrease by 1, but not below 0. You may choose any purchase order and any number of purchases. Find the maximum total points.

输入格式

The first line contains n and the second line contains n initial point values. The original bounds are 1≤n≤100000, 0≤deals[i]≤1000000.

输出格式

Output a single integer, the answer.

样例 1

输入:

5
5 2 2 3 1

输出:

7

样例 2

输入:

3
5 5 5

输出:

12

样例 3

输入:

3
0 1 0

输出:

1

样例说明

The outputs of the three public examples are 7; 12; and 1, checked by independent enumeration or direct simulation.