import itertools n=int(input()) l = list(map(int,input().split())) sum = 0 for i,j in itertools.product(l,l): sum += i**j print(sum)