MOD = 10**9 + 7
#puts MOD
count = gets.to_i
numbers = gets.chomp.split.map {|n| n.to_i % MOD}

result = 0
prev_sum = numbers.sum
count.times do
  current = numbers.shift
  current_sum = prev_sum = prev_sum - current
  # sum = 0 
  # numbers.each do |n|
    # result += current * n
  # end
  sum = current_sum * current
  result += sum
end
  
puts result % MOD
