def check(): ret = 0 idx = 0 for k in range(n): for _ in range(pow(2,k)): ret += A[idx] * k idx += 1 if idx == n: return ret n = int(input()) A = list(map(int,input().split())) A.sort(reverse=True) print(check())