n = gets.to_i
array = gets.split(" ").map(&:to_i)
array_sum = array.sum
sum = 0
previous = 0
mod = 10 ** 9 + 7
(array.length-1).times do |i|
  if i == 0
    previous = array[i]
  else
    previous += array[i]
  end
  sum += array[i] * (array_sum - previous)
end
puts sum % mod