program sum_of_product
    implicit none
    integer(8) n, i, j, sum,b, ans
    integer(8),allocatable :: a(:)

    read *, n
    allocate(a(n))
    read *, a
    sum=0

    do i=1,n-1
        do j=i+1,n
            if(j<=n)then
                if(i/=j)then
                b=a(i)*a(j)
                sum=sum+b
                end if
            else
                exit
            end if
        end do
    end do
    ans=mod(sum,1000000007)
    print *,ans
end program sum_of_product