from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline N = int(input()) A = list(map(int,input().split())) C = Counter(A) ans = 0 for k,v in C.items(): for k2,v2 in C.items(): ans += v*v2*pow(k,k2) print(ans)