program takoyaki
  implicit none
  integer,allocatable :: d(:)
  integer ::n,i,j
  integer ::sum
  
  read (*,*)n
  allocate(d(n))
  read(*,*) (d(i),i=1,n)
  sum = 0
  do i = 1,n-1
     do j = i+1,n
       sum = sum + d(i)*d(j)
     end do
   end do
  write(*,*) sum
        
end program takoyaki
