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

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

p sum