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

sums = []
sum = 0
total = as.sum
as.each_with_index do |a, i|
  sums << (total - sum) % (10**9+7)
  sum += a
end

ans = 0
(0..n-2).each do |i|
  ans += (as[i] * sums[i+1]) % (10**9+7)
end

puts ans % (10**9+7)