MOD = 10 ** 9 + 7
ONE = '1'.freeze

def nCk(n, k)
  return 0 if n < k
  (fact(k + 1, n) * inv(fact(1, n - k) % MOD)) % MOD
end

def fact(s, e)
  (s..e).inject(1) { |r, i| (r * i) % MOD }
end

def inv(x)
  res = 1
  beki = x
  (MOD - 2).to_s(2).reverse.chars do |digest|
    res = (beki * res) % MOD if digest == ONE
    beki = (beki * beki) % MOD
  end
  res
end

n, k = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i).sort

max_counts = n.times.map { |i| nCk(i, k - 1) }
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
