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

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

  diff += num
  sum += num * (a_sum - diff)
end

puts sum % (10 ** 9 + 7)
