N=int(input()) A=list(map(int,input().split())) cnt=[0]*9 for a in A: cnt[a]+=1 ans=0 for a in range(1,9): for b in range(1,9): ans+=a**b*cnt[a]*cnt[b] print(ans)