MOD = 10 ** 9 + 7
N = gets.to_i
A = gets.split.map &:to_i

b = Array.new(N+1, 0) # 累積和テーブル
N.times { |i| b[i+1] = b[i] + A[i] }

ans = 0
N.times do |i|
  # 累積和を使って A[i+1] + ... + A[N] を求める
  sum = (b[-1] - b[i+1]) % MOD

  ans += A[i] * sum
  ans %= MOD
end

p ans