n = gets.strip.to_i
a = gets.strip.split.map(&:to_i)

sum = 0
diff = 0
a.each_with_index do |num, i|
  break if a.length - 1 == i

  diff += a[i]
  sum += a[i] * (a.sum - diff)
end

puts sum % (10 ** 9 + 7)
