M = 10**9 + 7
gets
A = gets.split.map(&:to_i)

s = 0

S = A.reverse.map do |a|
  s += a
  s %= M
end.reverse

# pp S

w = 0

(A.length - 1).times do |i|
  w += (A[i] * S[i + 1]) % M
  w %= M
end

puts w
