N,K,*as=$<.read.split.map(&:to_i)
m=10**9+7

as.sort!

if K == 1
  puts as[-1] - as[0]
  exit 0
end

i = N-K
j = 1
t = 1
ret = 0
min = 0
max = 0
while 0<=i
  min += as[i]*t % m
  max += as[j+K-2]*t % m
  t = (t * (K-1+j) / j)%m
  i-=1
  j+=1
end
ret=(max-min)%m

puts re