  N = 10**9+7

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

  sum = 0
  0.upto(n-2) do |i|
    (arr[i,1] * (n-i-1)).zip(arr[i+1..n-1]).map {|a,b| a * b }.each {|e| sum  = (sum + e) % N }
  end
  puts sum
