      PROGRAM takoFes
      IMPLICIT NONE
      INTEGER :: N
      INTEGER,ALLOCATABLE :: d(:)
      INTEGER(8) :: ans
      
      INTEGER :: a,piyo
      READ*,N
      ALLOCATE( d(N) )
      read*,d(:)
      
      ans = 0
      DO a = 1,N-1
        piyo = sum(d(a+1:N))
        ans = ans + d(a)*piyo
      END DO
      
      print*,ans
      
      
      END PROGRAM