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