def pow(x,n)
  if n == 0
    1
  elsif n % 2 == 0
    pow(x*x%MOD, n/2) % MOD
  else
    x * pow(x, n-1) % MOD
  end
end
MOD = 1000000007
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
sum = 0
a.each do |x|
  sum += x
  sum %= MOD
end
ans = 0
a.each do |x|
  v = sum - x
  v %= MOD
  ans += x * v
  ans %= MOD
end
ans = ans * pow(2,MOD-2) % MOD
puts ans