N = int(input()) A = list(map(int, input().split())) B = [0] * 9 for k in range(9): for a in A: B[k] += pow(a, k) ans = 0 for a in A: ans += B[a] print(ans)