n = int(input()) a = list(map(int, input().split())) cnt = [0 for _ in range(9)] for i in range(n): cnt[a[i]] += 1 ans = 0 for x in range(1, 9): for y in range(1, 9): ans += cnt[x] * cnt[y] * (x ** y) print(ans)