from itertools import accumulate
n=int(input())
d=list(map(int,input().split()))
ans=0
for i in range(n):
  ans+=(list(accumulate(d))[-1]-d[i])*d[i]
print(ans//2) from itertools import accumulate n=int(input()) n int(input()) int input() input d=list(map(int,input().split())) d list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ans=0 ans 0 for i in range(n):
  ans+=(list(accumulate(d))[-1]-d[i])*d[i] i range(n) range n ans+=(list(accumulate(d))[-1]-d[i])*d[i] ans (list(accumulate(d))[-1]-d[i])*d[i] list(accumulate(d))[-1]-d[i] list(accumulate(d))[-1] (accumulate(d)) list accumulate(d) accumulate d -1 d[i] d i d[i] d i print(ans//2) print ans//2 ans 2 n=int(input()) int(input()) n ans+=(list(accumulate(d))[-1]-d[i])*d[i] (list(accumulate(d))[-1]-d[i])*d[i] ans d=list(map(int,input().split())) list(map(int,input().split())) d ans=0 0 ans
from itertools import accumulate
n=int(input())
d=list(map(int,input().split()))
ans=0
for i in range(n):
  ans+=(list(accumulate(d))[-1]-d[i])*d[i]
print(ans//2)