#!/usr/bin/env ruby

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

D = 10 ** 9 + 7

sum = [0]

1.upto(N) do |i|
  sum[i] = sum[i-1] + A[i-1]
end

ans = 0

0.upto(N-2) do |i|
  #p "#{A[i]} * (#{sum[N]} - #{sum[i+1]})"
  ans += A[i] * (sum[N] - sum[i+1])
  ans %= D
end

puts ans
