LIMIT = 10 ** 9 + 7

def factorial(n)
  result = 1
  2.upto(n) {|i| result *= i}
  result
end

def permutation(a, b)
  [*1..a].last(b).inject(1, &:*)
end

memo = {}

combination = ->(a, b) {
  tmp = memo[[a, b]]
  return tmp if tmp
  memo[[a, b]] = permutation(a, b) / factorial(b)
}


n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i).sort
sum = 0

if k == 1
  puts 0
  exit
end

(0..n - k).each do |min|
  (min + k - 1..n - 1).each do |max|
    f = as[max] - as[min]
    sum += f * combination.(max - min - 1, k - 2)
  end
end

puts sum % LIMIT