using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace AtCoder
{
    class Abc162F
    {

        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());

            var a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            Array.Sort(a);
            Array.Reverse(a);

            long max = 0;
            int i = 0, j = n;
            while(i<j)
            {
                max = max + a[i] * (Math.Abs(j - (i+1))) + a[j-1] * (Math.Abs(j - (i+1)));
                i++;
                j--;
            }

            Console.Write(max);
            Console.WriteLine();

        }
    }
}
