program sum_of_product
    implicit none
    integer(8) n, i, y,ans,x,z,j
    integer(8),allocatable :: a(:)

    read *, n
    allocate(a(n))
    read *, a
    y=0
    x=0
    z=0
    j=0

    if(2<=n .or. n<=200000)then
        do i=1,n
            if(0<=a(i) .or. a(i)<=1000000000)then
                x=x+a(i)
                y=mod((sum(a)-x),1000000007)
                z=y*a(i)
                j=j+z
            end if
        end do
    end if
    ans=mod(j,1000000007)
    print *,ans
end program sum_of_product