program Spp
    implicit none
    integer(16),allocatable :: a(:)
    integer :: n, i
    integer(16) :: ans = 0, t = 0
    read *, n
    allocate(a(n))
    read *, a(1:n)
    t = sum(a(1:n))
    do i = 1, n-1
        t  = t - a(i)
        ans = ans + t * a(i)
    end do
    ans = mod(ans, 1000000007)
    print *, ans
end program