N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort
comb = (0..N-1).to_a.combination(K).to_a
data = Array.new(N, 0)
comb.each do |ary|
  data[ary.first] -= 1
  data[ary.last]  += 1
end

res = 0
N.times do |i|
  res += A[i] * data[i]
end
p res % (10**9 + 7)