N = int(input()) A = list(map(int, input().split())) from collections import defaultdict dic = defaultdict(int) for a in A: dic[a] += 1 ans = 0 for i in range(1, 9): for j in range(1, 9): ans += dic[i] * dic[j] * i ** j print(ans)