Competitions
Greedy
Cafe "Proboscis"
The new cafe "Proboscis" is opened in the city of Е. for elephants. All clients come to the cafe at the time 0, and the owner chooses the order in which to serve them. Every second only one elephant is served (the first one is served at the time 0).
The owner knows that if the elefant i will be served at the time t, he will pay tips[i]
- t tips. If the number tips[i]
- t is negative, he will pay nothing. Help the owner to find the service order of elephants that will bring him the maximum profit.
Input data
The first line contains the number of elephants n (0 ≤ n ≤ 100), arrived to cafe. The next line contains n numbers tips[1]
, tips[2]
, ..., tips[n]
(0 ≤ tips[i]
≤ 10^5
).
Output data
Print the maximum profit for cafe owners.
Examples
Input example #1
3 3 2 3
Output example #1
5