def binom(n:, k:)
  return 1 if n == k
  n.downto(1).inject(:*) / ((n-k).downto(1).inject(:*) * k.downto(1).inject(:*))
end

n, k = gets.chop.split.map(&:to_i)
a = gets.chop.split.map(&:to_i).sort
sum = 0
m = 1000000007

mins = a[0..n-k]
maxs = a.reverse[0..n-k]

(0..n-k).each do |i|
  c = binom(n:n-1-i, k:k-1)
  sum += c * (maxs[i] - mins[i])
  sum %= m
end
puts sum