program main
  implicit none
  integer :: N
  integer(8), allocatable  :: A(:)
  integer :: i,j
  integer(8) :: out
  read(*,*) N
  allocate(A(N))
  read(*,*) A(:)

  out = 0
  !
!!  do i = 1,N-1
!!     do j= i+1,N
!!        out = out + mod(A(i)*A(j),10**9+7)
!!        out = mod(out,10**9+7)
!!     end do
!!  end do
  do i = 1,N-1
     out = out + mod(A(i)*sum(A(i+1:N)), 10**9+7)
     out = mod(out,10**9+7)
  end do
   write(*,'(i0)') out
end program main
