import math n = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) cost = 0 for i in range(n): cost += int(math.log2(i+1)) * A[i] print(cost)