N = int(input()) A = list(map(int,input().split())) C = 9 dat = [0] * C for a in A: dat[a] += 1 ans = 0 for i in range(1,C): for j in range(1,C): tmp = i ** j ans += tmp * dat[i] * dat[j] print(ans)