MOD = 1_000_000_007

_ = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_i)
r_arr = arr.reverse
r_arr_sums = []
tmp = 0
r_arr.each do |s|
  r_arr_sums << ((tmp += s) % MOD)
end

ans = 0
r_arr_sums.pop # 最後の要素はいらん
r_arr_sums.reverse.each_with_index do |sum, i|
  ans = (ans + (arr[i] * sum) % MOD)% MOD
end

puts ans