program answer
  implicit none
  integer(16) :: i, j, N, s, ans
  integer(16), allocatable :: A(:)
  read(*,*) N
  allocate(A(N))
  read(*,*) A
  s=0
  do i = 1, N-1
     do j = i+1, N
        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
  end do

  write(*,*) s
  stop
 end program answer