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

a = gets.chop.split.map(&:to_i).sort
sum = 0
 
t_n = n-1
t_i = 1
loop do
  c = bincom[t_n] * bincominv[k-1] * bincominv[t_n-k+1]
  sum += c * (a[-t_i] - a[t_i-1])
  sum %= m
  break if t_n == k-1
 
  t_n -= 1
  t_i += 1
end
puts sum