num = gets.strip.to_i
array = gets.strip.split.map(&:to_i)

total = array.inject(0){|r, n| r+= n} - array[0]
sum = 0
num.times do |i|
  sum += (array[i] * total) % (10 ** 9 + 7)
  total -= array[i + 1].to_i
end

puts sum % (10 ** 9 + 7)

