n, k = gets.chop.split.map(&:to_i)
a = gets.chop.split.map(&:to_i).sort
sum = 0
m = 1000000007

counts = (k-1..n-1).map { |i| (1..i).to_a.combination(k-1).count }.reverse
mins = a[0..n-k]
maxs = a.reverse[0..n-k]

counts.each_with_index do |c, i|
  sum += c * (maxs[i] - mins[i])
  sum %= m
end
puts sum
