n, k = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i)

combos = nums.combination(k).to_a

sum = 0

combos.each do |combo|
  f = combo.max - combo.min
  sum += f
  sum %= 1000000007
end

puts sum