program C
    implicit none

    integer(4) :: N
    integer(16), allocatable :: A(:) 
    integer(4) :: i, j
    integer(16) :: sum

    read(*, *) N

    allocate(A(1:N))
    read(*, *) A

    sum = 0
    do i = 1, N
        do j = i+1, N
            sum = sum + A(i)*A(j)
            if (sum > 10**9 + 7) then
                sum = mod(sum, 10**9 + 7)
            end if
        end do
    end do

    write(*, *) sum

end program C