It's the day of the Don Mills Programming Gala! Roger's professional advertising skills have gotten students to come to the contest!
The DMPG has a reputation for being a premier programming contest in Canada, but that doesn't stop some students from failing to appreciate all of Roger's efforts. Roger assigns all of these students a monkeyness level. He now needs to check in all of these monkeys into DMPG. Magically, Roger has discerned that no two of these monkeys are identical in terms of how much of a monkey they are.
Roger wishes to check in the students in increasing monkeyness level. However, the students have lined up in arbitrary order, so he dispatches his loyal assistant Jessica to handle this.
Jessica, unlike Roger, is not a monkey. She can convince any two monkeys with monkeyness levels and to switch positions, but it will increase her frustration by units. Compute the minimum frustration Jessica will have after sorting all of the monkeys.
Constraints
All are distinct.
Input Specification
The first line will contain a single integer .
Each of the next lines will contain an integer , the monkeyness of the th person in line.
Output Specification
Output the minimum frustration Jessica can have after sorting all the monkeys.
Sample Input
3
2
3
1
Sample Output
7
Comments