program C177
    implicit none
    integer(8) :: N
    integer(8), allocatable, dimension(:) :: A
    integer(8) :: i, j, ans

    read(5,*) N
    allocate(A(N))
    read(5,*) (A(i), i = 1, N)

    ans = 0
    do i = 1, N-1
        do j = i+1, N
            ans = ans + A(i)*A(j)

            if (ans > 1000000007) then
                ans = mod(ans,1000000007)
            end if
        end do
    end do

    write(6,*) ans


    
end program C177