output_description: Print the answer \bmod (10^9+7).
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
      A_1 ... A_N
attempt: import operator as op
  from functools import reduce
  
  
  def ncr(n, r):
      r = min(r, n - r)
      numer = reduce(op.mul, range(n, n - r, -1), 1)
      denom = reduce(op.mul, range(1, r + 1), 1)
      return numer / denom
  
  
  def main():
      N, K = list(map(int, input().split()))
      As = list(map(int, input().split()))
      As.sort()
      mod = 10**9 + 7
  
      s = 0
      for i in range(N):
          for j in range(i + K - 1, N):
              # print(i, j, (As[j] - As[i]) , ncr(j-i-1, K-2), ncr(2, 3))
              s += (As[j] - As[i]) * ncr(j - i - 1, K - 2)
  
      # combs = combinations(range(N), K)
      # for tup in combs:
      #     mn_idx = tup[0]
      #     mx_idx = tup[-1]
  
      #     s +=  As[mx_idx] - As[mn_idx]
  
      print(int(s % mod))
  
  
  if __name__ == "__main__":
      main()
  
problem_description: Statement
  
  For a finite set of integers X, let f(X)=\max X - \min X.
  
  Given are N integers A_1,...,A_N.
  
  We will choose K of them and let S be the set of the integers chosen. If we
  distinguish elements with different indices even when their values are the
  same, there are {}_N C_K ways to make this choice. Find the sum of f(S) over
  all those ways.
  
  Since the answer can be enormous, print it \bmod (10^9+7).
samples: [{"input": "4 2\n    1 1 3 4", "output": "11\n    \n\nThere are six ways to choose S:\n\\\\{1,1\\\\},\\\\{1,3\\\\},\\\\{1,4\\\\},\\\\{1,3\\\\},\\\\{1,4\\\\}, \\\\{3,4\\\\} (we distinguish\nthe two 1s). The value of f(S) for these choices are 0,2,3,2,3,1,\nrespectively, for the total of 11.\n\n* * *"}, {"input": "6 3\n    10 10 10 -10 -10 -10", "output": "360\n    \n\nThere are 20 ways to choose S. In 18 of them, f(S)=20, and in 2 of them,\nf(S)=0.\n\n* * *"}, {"input": "3 1\n    1 1 1", "output": "0\n    \n\n* * *"}, {"input": "10 6\n    1000000000 1000000000 1000000000 1000000000 1000000000 0 0 0 0 0", "output": "999998537\n    \n\nPrint the sum \\bmod (10^9+7)."}]