n = gets.chomp.to_i
arr = gets.chomp.split(' ').map(&:to_i)
mod = 1000000007

i = 0
sum = 0
each_sum = 0
while i < n-1
  each_sum += arr[i]
  sum += arr[i] * (arr.sum - each_sum)
  # a*b+ a*c + a*d + b*c + b*d + c*d  
  # a(b+c+d) + b(c+d) + 
  # 
  #
  i += 1
end
puts sum%mod