#!/usr/bin/env ruby
# require 'pry'

# dpテンプレ

n = gets.chomp.to_i
a = gets.split(' ').map(&:to_i)
sum = 0
ruiseki = a.sum
(n-1).times do |i|
  ruiseki -= a[i]
  sum += a[i] * ruiseki
end

puts sum % (10**9 + 7)