본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 16208번 귀찮음

by 현장 2022. 5. 8.

-Code

n = int(input())
steel_stick = sorted(list(map(int, input().split())))
total_len = sum(steel_stick)
cost = 0
for i in steel_stick:
    total_len -= i
    cost += total_len * i
print(cost)