# frozen_string_literal: true

MOD = 10**9 + 7
n = gets.to_i
a = gets.split.map(&:to_i)
b = []
sum = 0
(0..(n - 2)).each do |i|
  sum += a[i]
  sum %= MOD
  b.push sum
end

sum = 0
(1..(n - 1)).each do |i|
  sum += a[i] * b[i - 1]
  sum %= MOD
end

puts sum
