MAX = 10000
MOD = 10 ** 9 + 7
 
def mod_power(n, p, m)
  #フェルマーの小定理
  return 1 if p == 0
  if p % 2 == 0
    t = mod_power(n, p / 2, m)
    return t * t % m
  else
    return n * mod_power(n, p - 1, m) % m
  end
end
 
def cominit()
  #階乗と階乗の逆元を用意する
  @fac = []
  @fac[0] = 1
  @fac[1] = 1
  @finv = []
  @finv[0] = 1
  @finv[1] = 1
 
  2.upto(MAX) do |i|
    @fac[i] = @fac[i-1] * i % MOD
  end
 
  @finv[MAX] = mod_power(@fac[MAX], MOD - 2, MOD)
  (MAX-1).downto(2) do |i|
    @finv[i] = @finv[i+1] * (i + 1) % MOD
  end
end
 
def comb(n, r)
  return 0 if n < r
  return 1 if n == r
  return @fac[n] * @finv[r] * @finv[n - r] % MOD
end
 
def main
  n, k = gets.chomp.split.map(&:to_i)
  array = gets.chomp.split().map(&:to_i).sort.reverse
  cominit()
  ans = 0
  #各Ciについてmax, minを求める
  array.each_with_index do |c, i|
    next if i > n - k
    higher_count = array[i+1..n-1].select {|a| a <= c}.length
    ans += c * comb(higher_count, k - 1) % MOD
  end
 
  array.sort!
 
  array.each_with_index do |c, i|
    #ciより低いもののカウント
    next if i > n - k
    lower_count = array[i+1..n-1].select {|a| a >= c}.length
    ans -= c * comb(lower_count, k - 1) % MOD
  end
 
  return ans % MOD
end
 
puts main