program takoyaki_festival_2019
    implicit none
    integer(4):: n
    integer(4), allocatable:: d(:)
    integer(4):: ans=0
    
    read*, n
    allocate(d(n))
    read*, d(:)
    block; integer(4):: i,j
        do i=1, n-1
            ans = ans + sum(d(i)*d(i+1:n))
        end do
    end block

    print*, ans
end program takoyaki_festival_2019