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

A = 10 ** 9 + 7
result = 0
base = 0
(n-2).downto(0) do |i|
  base += arr[i+1]
  tmp = (base * arr[i]) % A
  result += tmp
  result %= A
end

puts result
