n = gets.chomp.to_i
nl = gets.split.map(&:to_i)
mod = 1000000007
acc_table = []
n.times do |i|
  acc_table[i] = 0
end
nl.each_with_index do |x,i|
  acc_table[i+1] = x + acc_table[i]
end

result = 0
nl.each_with_index do |x,i|
  sum = (acc_table[n] - acc_table[i + 1]) % mod
  result += nl[i] * sum
  result %= mod
end
puts result