N = gets.to_i
A = gets.chomp.split.map(&:to_i)
sum = 0
x = 0

(0..N-1).each do |i|
  sum += A[i]**2%1000000007
  sum %= 1000000007
  x += A[i]
  x %= 1000000007
end

y = x**2%1000000007

if y>=sum
  puts (y-sum)/2
else
  puts (y+1000000007-sum)/2
end


