N=int(input()) A=list(map(int,input().split())) R=0 for i in range(1,9): for j in range(1,9): R+=(A.count(i)*A.count(j)*(i**j)) print(R)