n, k = gets.chop.split.map(&:to_i)
bincom = 1.upto(n).inject([1]) { |acc, cur| acc << (acc.last * (cur % m)) % m; acc; }

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

t_n = n-1
t_i = 1
loop do
  c = bincom[t_n] / (bincom[k-1] * bincom[t_n-k+1])
  sum += (c * ((a[-t_i] - a[t_i-1]) % m)) % m
  sum %= m
  break if t_n == k-1

  t_n -= 1
  t_i += 1
end
puts sum
