Little E's array
题号:NC223764
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

    One day little E gets an array of length n, with numbers from left to right subscript  to , we named it  ,and you can rearrange the array any way you want.

    When one of these numbers goes from subscript to subscript , then that number can contribute  points. little E wants to ask you to get the maximum score by rearranging the array of A's in you hand

输入描述:

The first line contain one integer 

The second line contain n integers


输出描述:

Print one integer — the maximum score
示例1

输入

复制
4
1 2 3 4

输出

复制
51
示例2

输入

复制
4
1 3 4 2

输出

复制
40