时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒 空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M 64bit IO Format: %lld
题目描述
Walk Alone has piles of stones, and there are stones in the -th pile.
He can do an operation to these stones for times. In each operation, he can select two piles of stones of size and , and merge them (the two piles will become a larger pile of size ), and he will get score after that.
Walk Alone wants to know the maximal total score he can get. Can you help him?
输入描述:
The first line contains an integer , the number of piles of stones.
The second line contains integers. The -th integer indicates the number of stones in the -th pile.
输出描述:
Output an integer representing the maximal score Walk Alone can get.