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