integer N
integer,allocatable,dimension(:)::d,SUMS
integer ans
read*,N
allocate(d(N),SUMS(N))
read*,d
SUMS(N)=0
do i=N-1,1,-1
  SUMS(i)=SUMS(i+1)+D(i+1)
end do
ans=0
do i=1,N
  ans=ans+SUMS(i)*D(i)
end do
print"(i0)",ans
end
