n = input()
people = list(map(int,input().split()))
people.sort()
time = 0
for i,person in enumerate(people):
time += person* (len(people)-i)
print(time)
만약)
1 2 3 3 4 의 시간이 걸린다면
1
1+2
1+2+3
1+2+3+3
1+2+3+3+4
이기 때문에 규칙을 발견할 수 있다
sort는 함수가 O(nlogn)
enumerate 와 for 에서 O(n) 을 가지기 때문.
n = input()
people = list(map(int,input().split()))
people.sort()
time = 0
for i in range(n):
time += people[i] * (n-i)
print(time)