program c177

implicit none
integer(16) :: n, ans, i, j, sum
integer(16), allocatable :: a(:), p(:)

read *, n
allocate(a(1:n))
allocate(p(1:n))

read *, a(:)

ans = 0
p(:) = 0

do i = n-1, 1, -1
 p(i) = p(i+1) + a(i+1)
end do

!print *, p(:)

do i = 1, n-1
 ans = ans + a(i) * p(i)
 !print *, a(i)*p(i)
end do

print *, mod(ans,1000000007)

end program c177