n, k, *a = $stdin.read.split.map(&:to_i)
M = 10**9 + 7

def fsum(n, k, a)
  x = Array.new(n)
  (n -k + 1).times.lazy.zip(a).inject(0) { |sum, (i, a_k)| x.pop; (sum + a_k * x.combination(k - 1).size) % M }
end

min_sum = fsum(n, k, a.sort!)
max_sum = fsum(n, k, a.reverse!)

puts (max_sum - min_sum) % M
