NTKM - DIEULINH

no tags 

Minh has n piles of pebbles. The i-th pile has a[i] pebbles. The cost to merge 2 piles is the total of pebbles in this 2 piles. Calculate the cost to merge all these piles so that the cost is lowest.

Input

_ The first line is number N.

_ Next are n integers which is the number of pebbles in N piles.

Output

Result: write down the lowest cost

Example

Input:
5
4 1 2 7 5

Output:
41
n < 1000, a[i] < 1000000000
Note: sorry about my english ^^

Added by:Minh^^
Date:2011-06-13
Time limit:0.5s-1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM32-GCC GAWK MAWK BC C-CLANG NCSHARP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JS-MONKEY JULIA KTLN NIM NODEJS OBJC OBJC-CLANG OCT PICO PROLOG PYPY PYPY3 PY_NBC R RACKET RUST CHICKEN SED SQLITE SWIFT UNLAMBDA VB.NET
Resource:[C11]