n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i);


sum = 0

for i in 0..(a.length-1) do
	sum +=a[i]
end

ans =0
for i in 0..(a.length-2)
	sum = sum-a[i]
	ans += a[i]*sum
end

puts ans.modulo(1000000007)

