require 'pp'
N, K = gets.split.map &:to_i
factK2 = (1..K-2).inject(1, :*)
A = gets.split.map(&:to_i).sort
ans = 0
for i in 0..N-K
    for j in i+K-1..N-1
        num = (j-i-1-K+2+1..j-i-1).inject(1, :*) / factK2
        ans += (((A[j] - A[i]) % (10**9 + 7)) * num) % (10**9 + 7)
    end
end
p ans % (10**9 + 7)