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