mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) F = [] for i in range(20): F.extend([i] * (1 << i)) ans = 0 for i in range(N): ans += A[i] * F[i] print(ans) if __name__ == '__main__': main()