MOD = 10 ** 9 + 7
n = gets.to_i
a = gets.split.map(&:to_i)
b = Array.new(n, 0)
prev = 0
for i in 0...n do
  b[i] = (prev + a[i]) % MOD
  prev = b[i]
end
sum = 0
for i in 0...(n - 1) do
  sum = (sum + a[i] * (b[n - 1] - b[i])) % MOD
end
puts sum
