n = gets.to_i
a = gets.split.map(&:to_i)
MOD = 10**9+7
tos = Array.new(n)
tos[0] = a[0]
for i in 1..(n-1)
  tos[i] = tos[i-1] + a[i]
end
sum = 0
for j in 0..(n-1)
  sum += a[j]*((tos[n-1]-tos[j])%MOD)%MOD
  sum %= MOD
end
puts sum