mod = 1_000_000_007

n = gets.to_i
a = gets.split.map &:to_i

tmp0 = a.sum
tmp0 = ((tmp0 % mod) ** 2) % mod
tmp1 = a.sum { |e| e ** 2 } % mod
ans = tmp0 < tmp1 ? tmp0 - tmp1 + mod : tmp0 - tmp1

if ans.odd?
  puts (ans + mod) / 2
else
  puts ans / 2
end
