n, k = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i).sort
max_counts = [*[0] * (k - 1), 1]
(n - k).times { |i| max_counts << max_counts.last * (i + k) / (i + 1) % MOD }
min_counts = max_counts.reverse

max_sum = 0
min_sum = 0

nums.each_with_index do |num, index|
  max_sum += num * max_counts[index]
  min_sum += num * min_counts[index]
end

puts (max_sum - min_sum) % MOD
