require 'pp'

MOD = 10 ** 9 + 7
n = gets.to_i
a_n = gets.split.map(&:to_i)


memo = Array.new(n, 0)
memo[n-1] = a_n[n-1]
(n-2).downto(0) do |i|
    memo[i] = (memo[i+1] + a_n[i]) % MOD
end

sum = 0
(n-2).downto(0) do |i|
    sum = (sum + (a_n[i] * memo[i+1]) % MOD) % MOD
end

puts sum
