program main
  implicit none
  integer :: N
  integer(8), allocatable  :: A(:)
  integer :: i,j
  integer(8) :: out, A_sum, idiv
  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
  A_sum = sum(A)
  idiv = int(10**9+7,8)
  do i = 1,N-1
     A_sum = A_sum - A(i)
     out = mod( out + A(i)*mod(A_sum,idiv), idiv ) 
  end do
  write(*,'(i0)') mod(out,idiv)
  deallocate(A)
end program main
