MOD = 10**9 + 7
FACT = []
INV = []
def conv(s,t)
  (FACT[s] * INV[s-t] % MOD) * INV[t] % MOD
end
def calc_fact(n)
  FACT[0] = 1
  INV[0] = pow(FACT[0], MOD-2)
  for i in 1..n
    FACT[i] = FACT[i-1] * i % MOD
    INV[i] = pow(FACT[i], MOD-2)
  end
end
def pow(x,n)
  if n == 0
    1
  elsif n % 2 == 0
    pow(x*x%MOD, n/2) % MOD
  else
    x * pow(x, n-1) % MOD
  end
end

n, k = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
calc_fact(n)
a.sort!
min_sum = 0
max_sum = 0
for i in 0..n-k
  min_sum += a[i] * conv(n-(i+1),k-1)
  max_sum += a[n-1-i] * conv(n-(i+1),k-1)
  min_sum %= MOD
  max_sum %= MOD
end
ans = max_sum - min_sum
ans %= MOD
puts ans