num = gets.strip.to_i
array = gets.strip.split.map(&:to_i)

p_arr = array.product(array)

cnt = 0
sum = p_arr.inject(0) do |a, item|
  a += item[0] * item[1]   if (cnt / 3) < (cnt % 3)
  cnt += 1
  a
end

puts sum % (10 ** 9 + 7)