import sys input = sys.stdin.readline N=int(input()) A=list(map(int,input().split())) ANS=0 now=0 for a in A: ANS+=now*a now+=a print(ANS)