n = gets.to_i
as = gets.split(' ').map(&:to_i)

rsums = []
rsum = 0
as.reverse_each do |a|
  rsum += a
  rsums.unshift(rsum)
end

M = (10 ** 9) + 7

sum = 0
(0...n-1).each do |i|
  sum = (sum + as[i] * rsums[i + 1]) %  M
end
puts sum
