unuse = gets.chomp.to_i
sum = 0
ans = 0
gets.chomp.split.map do |i|
  i = i.to_i
  ans += (sum * i)
  sum += i
end
# sum = 0
# (s-1).times do |cnt|
#   sum += num[cnt]*num[cnt+1..s-1].sum
# end
#puts sum % (7 + 10**9)
puts ans % (7 + 10**9)