if __name__=='__main__': n = int(input()) q = list(map(int,input().split())) q.sort() res = 0 for i in range(n): res += q[i] * (n - 1 - i) print(res)