#組み合わせ個数
def choose(n, r, mod)
  return 0 if not (0 <= r and r <= n)
  return 1 if r == 0 or r == n
  fact(n, mod) * inverse(fact(r, mod) * fact(n-r, mod) % mod, mod) % mod
end
#階乗(MODあり)
@fact = [1]
def fact(n, mod)
  if n > @fact.size then
    f = @fact[-1]
    (@fact.size+1..n).each{|i|
      f = (f * i) % mod
      @fact << f
    }
  end
  @fact[n-1]
end
#逆元(MODあり)
def inverse(x, mod)
  pow(x, mod-2, mod)
end
#べき乗(MODあり)(繰り返し２乗法)
def pow(x, n, mod)
  ans = 1
  while n > 0
    ans = ans * x % mod if n.odd?
    x = x * x % mod
    n >>= 1
  end
  ans
end

N, K = gets.chomp.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i)
MOD = 10 ** 9 + 7

A.sort!
ans = 0
(0..(N - K)).each{|i|
  ans = (ans + (A[N - 1 - i] - A[i]) * choose(N - 1 - i, K - 1, MOD)) % MOD
}

puts ans
