from collections import Counter N = int(input()) A = list(map(int, input().split())) freq = Counter(A) ans = 0 for k, v in freq.items(): for i in range(1, 9): # k^i の個数 cnt = v * freq[i] ans += pow(k, i) * cnt print(ans)