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

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

    if(2<=n .or. n<=200000)then
        do i=1,n-1
            if(0<=a(i) .or. a(i)<=1000000000)then
                do j=i+1,n
                    if(i<j .and. j<=n)then
                        b=mod(a(i),1000000007)
                        c=b*a(j)
                        sum=sum+c
                     else
                        exit
                    end if
                end do
            endif
        end do
    end if
    ans=mod(sum,1000000007)
    print *,ans
end program sum_of_product