# n = gets.chomp.to_i
# a = gets.chomp.split(" ").map(&:to_i)
# ans = 0
mod = 10 ** 9 + 7

# i = 0
# while true
#     t = i + 1
#     kake = 0
#     until t == n 
#     kake += (a[t] % mod)
#     t += 1
#     end
#     ans = ans + (a[i] * kake) % mod
#     ans %= mod
#     if i == n - 2
#         break
#     end
#     i += 1
# end
# puts ans
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
ans = 0
hiku = 0
a.each do |i|
    ans += i
    hiku += i * i
end
puts ((ans * ans - hiku)/ 2) % mod