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

    read *, n
    allocate(a(n))
    read *, a
    y=0
    x=0
    z=0
    j=0
    t=sum(a)
    do i=1,n
        x=x+a(i)
        y=t-x
        z=y*a(i)
        j=j+z
    end do
    ans=modulo(j,1000000007)
    print *,ans
end program sum_of_product