n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
m = 10 ** 9 + 7

com = Array.new(n, 0)
com[k-1] = 1
k.upto(n-1) {|i| com[i] = com[i-1] * i / (i - k + 1) % m}

ans = 0
(k-1).upto(n-1) {|i| ans += a[i] * com[i]}
0.upto(n-k) {|i| ans -= a[i] * com[n-i-1]}

p ans % m