import numpy
N = int( input())
a = list(map(int, input().split(' ')))
l = [0]*N

p = numpy.argsort(a)[::-1]
a = numpy.sort(a)[::-1]
maxmin = [1, N]
s = 0
for i, a_i in enumerate(a):
    if p[i] + 1 > N/2 :
        s += (p[i] + 1  - maxmin[0])*a_i
        maxmin[0] = maxmin[0] + 1
        
    else:
        s += (maxmin[1]-p[i]-1)*a_i
        maxmin[1] = maxmin[1] - 1
        
print(s+1)