N = gets.to_i
As = gets.split.map &:to_i

MOD = 10**9 + 7

sums = []
As.reverse.each do |a|
    sums << ((sums.last || 0) + a) % MOD
end

sums.reverse!

p sums

ans = 0
(N-1).times do |i|
    ans += (As[i] * sums[i+1]) % MOD
    ans %= MOD
end

p ans