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 unittest
  
  
  class TestE(unittest.TestCase):
      def test_1(self):
          self.assertEqual(think(2, [1, 1, 3, 4]), 11)
  
      def test_2(self):
          self.assertEqual(think(3, [10, 10, 10, -10, -10, -10]), 360)
  
      def test_3(self):
          self.assertEqual(think(1, [1, 1, 1]), 0)
  
      def test_4(self):
          self.assertEqual(
              think(
                  6,
                  [
                      1000000000,
                      1000000000,
                      1000000000,
                      1000000000,
                      1000000000,
                      0,
                      0,
                      0,
                      0,
                      0,
                  ],
              ),
              999998537,
          )
  
  
  def solve():
      k, a = read()
      result = think(k, a)
      write(result)
  
  
  def read():
      n, k = read_int(2)
      return k, read_int(n)
  
  
  def read_int(n):
      return read_type(int, n, sep=" ")
  
  
  def read_float(n):
      return read_type(float, n, sep=" ")
  
  
  def read_type(t, n, sep):
      return list(map(lambda x: t(x), read_line().split(sep)))[:n]
  
  
  def read_line(n=0):
      if n == 0:
          return input().rstrip()
      else:
          return input().rstrip()[:n]
  
  
  def think(k, a):
      mode = 10**9 + 7
      n = len(a)
  
      fact_table, inverse_fact_table = prepare_fact_table(n, mode)
      a.sort()
  
      sum_of_max = 0
      sum_of_min = 0
  
      for i, x in enumerate(a):
          if i >= k - 1:
              sum_of_max += x * combination(
                  i, k - 1, fact_table, inverse_fact_table, mode
              )
              sum_of_max %= mode
          if n - i >= k:
              sum_of_min += x * combination(
                  n - i - 1, k - 1, fact_table, inverse_fact_table, mode
              )
              sum_of_min %= mode
  
      return (sum_of_max - sum_of_min) % mode
  
  
  def write(result):
      print(result)
  
  
  def prepare_fact_table(n, mode):
      fact_table = [1 for i in range(n + 1)]
      inverse_fact_table = [1 for i in range(n + 1)]
      for i in range(2, len(fact_table)):
          fact_table[i] = fact_table[i - 1] * i % mode
          inverse_fact_table[i] = divmod(fact_table[i], mode)
      return fact_table, inverse_fact_table
  
  
  def divmod(x, mode):
      return pow(x, mode - 2, mode)
  
  
  def combination(n, k, fact_table, inverse_fact_table, mode):
      return fact_table[n] * inverse_fact_table[k] * inverse_fact_table[n - k] % mode
  
  
  if __name__ == "__main__":
      # unittest.main()
      solve()
  
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)."}]