class Integer

  # O(min(n-k,k) log m)
  # combination: nPk / k! (mod p), note: m must be a prime number
  def cmb(k, m=10**9+7)
    n = self
    k = n - k if k > n - k
    n.prm(k, m) * k.prm(k,m).modinv(m) % m
  end

  # mod must be a prime number
  # O(log m)
  def modinv(mod = 10**9+7)
    pow(mod-2, mod)
  end

  # O(log n)
  def pow(n , mod = nil )
    a = self.to_i
    res = 1
    while n > 0
      if (n & 1) != 0
        res *= a
        res %= mod if mod
      end
      a *= a
      a %= mod if mod
      n >>= 1
    end
    res
  end
end


class Facts

  def initialize(mod=10**9+7, n_max=1)
    @mod = mod
    @n_max = n_max
    @fact = [1, 1]
    @inv = [0,1]
    @factinv = [1, 1]
    @perms = Hash.new{|h,k| h[k] = [1] }
    setup_table(n_max) if 1 < @n_max
  end

  def cmb(n,r)
    return 0 if r < 0 || n < r
    r = n - r if r > n - r
    setup_table(r) if @n_max < r
    prm(n,r) * @factinv[r] % @mod
    # @fact[n] * (@factinv[r] * @factinv[n-r] % @mod) % @mod
  end

  def factorial(n)
    prm(n,n)
  end

  def prm(n,k)
    if @perms[n][k].nil?
      perm = @perms[n]
      (n-perm.size+1).downto(n-k){|i| perm.push( perm[-1] * i % @mod )  }
    end
    return @perms[n][k]
  end

  private
    # O(t)
    def setup_table(t)
      (@n_max+1).upto(t) do |i|
        # @fact.push( @fact[-1] * i % @mod )
        @inv.push( -@inv[@mod % i] * (@mod / i) % @mod )
        @factinv.push( @factinv[-1] * @inv[-1] % @mod )
      end
      @n_max = t
    end
end

mod = 10 ** 9 + 7
 
n, k = gets.to_s.split.map{|i|i.to_i}
a    = gets.to_s.split.map{|i|i.to_i}.sort
 
f = Facts.new
 
ans = 0 
(n-k+1).times do |i|
  t = f.cmb( n-i-1, k-1 )
  mi = a[i] * t % mod
  ma = a[n-(i+1)] * t % mod
  ans += (ma - mi)
  ans %= mod if ans < 0 || mod <= ans
end
 
puts ans