program Spp
    implicit none
    integer(8),allocatable :: a(:)
    integer :: n, i
    integer(8) :: ans = 0
    read *, n
    allocate(a(n))
    read *, a(1:n)
    do i = 1, n-1
        ans = ans + sum(a(i+1:n)) * a(i)
    end do
    ans = mod(ans, 7+10**9)
    print *, ans
end program