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