program ABC177C
    implicit none
    integer(8)::N,m=1000000007,i,ans=0
    integer(8),allocatable::A(:),S(:)
    read*,N
    allocate(A(N))
    allocate(S(N))
    read*,A
    do i=1,N
        if(i==1)then
            S(i)=A(i)
        else
            S(i)=S(i-1)+A(i)
        end if
    end do

    do i=1,N-1
        ans=ans+mod(A(i)*(S(N)-S(i)),m)
        ans=mod(ans,m)
    end do
    print'(i0)',mod(ans,m)
end program ABC177C