N = gets.to_i
A = gets.split.map(&:to_i)
MOD = 10 ** 9 + 7
RUI = [0]

A.each do |a|
  RUI << RUI.last + a
end

ans = 0

A[0..-2].each_with_index do |a, idx|
  ans += a * (RUI.last - RUI[idx + 1])
  ans %= MOD
end

puts ans
