n, k = gets.chomp.split(' ').map(&:to_i)
as = gets.chomp.split(' ').map(&:to_i)
results = []
as.combination(k) do |ary|
  results << ary.max - ary.min
end
result = results.reduce(:+)
puts result % ((10 ** 9) + 7)
