program sum_of_product_of_pairs
  implicit none
  integer(16), parameter :: m = 1000000007
  integer(16), allocatable :: a(:)
  integer :: n
  read(*,*) n
  allocate(a(n))
  read(*,*) a
  write(*,'(i0)') mod((sum(a) ** 2 - sum(a ** 2)) / 2, m)
end program sum_of_product_of_pairs