program answer
  implicit none
  integer(16) :: i, j, N, s, t
  integer(16), allocatable :: A(:)
  read(*,*) N
  allocate(A(N))
  read(*,*) A
  s=0
  T=sum(A)
  do i = 1, N-1
     T=T-A(i)
     s=s+mod(A(i),10**9+7)*mod(T,10**9+7)
     s=mod(s,10**9+7)
        !s=s+mod(mod(A(i),10**9+7)*mod(A(j),10**9+7),10**9+7)
        !s=mod(s,10**9+7)
  end do

  write(*,*) s
  stop
 end program answer