  n = gets.to_i
  arr = gets.split(' ').map(&:to_i)
  num = 10**9 + 7
  sum = 0
  
  0.upto(n-2) do |i|
    #sum = (sum + arr[i+1..n-1].map {|e| arr[i] * e }.sum) % num
    sum += arr[i+1..n-1].map {|e| arr[i] * e }.sum
  end
  puts sum % num
