MOD = 1_000_000_007
io = DATA.eof? ? STDIN : DATA
n=io.gets.to_i
ar=io.gets.split.map(&:to_i)
ans=0
#累積和
cum=ar.clone
(ar.size-1).times do |i|
  cum[i+1]+=cum[i]
end

(n-1).times do |i|
  ans+=ar[i]*(cum[-1]-cum[i])
  ans%=MOD
end
puts ans
__END__
