program c177

implicit none
integer(16) :: n, ans, i, j
integer(16), allocatable :: a(:)

read *, n
allocate(a(1:n))

read *,  a(:)

do i = 1, n
 if(a(i) > 500000000) then
  a(i) = a(i) - 1000000007
 end if
end do

ans = 0

!print *, a(:)

do i = 1, n-1
 do j = i+1, n
  ans = ans + a(i) * a(j)
 end do
end do

if(ans < 0) then
 print *, mod(ans,1000000007) + 1000000007
else
 print *, ans
end if

end program c177