program sum_of_product_of_pairs
  implicit none
  integer(8), parameter :: m = 1000000007
  integer :: n, i
  integer(8) :: a(200000) = 0, s = 0, x = 0
  read(*,*) n
  read(*,*) a(1:n)
  s = a(n)
  do i = n - 1, 1, -1
    x = mod(x + s * a(i), m)
    s = mod(s + a(i), m)
  end do
  write(*,'(i0)') x
end program sum_of_product_of_pairs