def solve(): N=int(input()) A=list(map(int,input().split())) K=max(A) count=[A.count(i) for i in range(K+1)] ans=0 for a in range(K+1): for b in range(K+1): ans+=count[a]*count[b]*pow(a,b) return ans #================================================== print(solve())