program q_3
  implicit none
  integer(8) :: n,i,j,mo,seki,sum,tmp
  integer(8),allocatable :: A(:)

  mo = 10**9+7
  read(*,*) n
  allocate(A(n))
  read(*,*) A
  seki = 0
  sum = 0
  do i =1,n
     sum = sum + A(i)
  end do
!  write(*,*)sum                                                                                                                                                                                                  
  tmp = sum
  do i =1,n-1
     tmp = tmp - A(i)
 !    write(*,*)tmp                                                                                                                                                                                               
     seki = seki + mod(A(i)*mod(tmp,mo),mo)
!     do j = i+1,n                                                                                                                                                                                                
!        seki = seki + mod(A(i)*A(j),mo)                                                                                                                                                                          
!     end do                                                                                                                                                                                                      
  enddo
!  write(*,*) seki                                                                                                                                                                                                
  write(*,*) mod(seki,mo)

end program q_3