#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

long long int MOD = 1e9 + 7;

// calculate x%m for x "properly" for all x
long long int mod(long long int x, long long int m);

// calculate inverse of x in mod m
// if there is inverse of x   : return (inverse of x)
// if there is no inverse of x: return 0
long long int mod_inverse(long long int x, long long int m);

// calculate inverse of x in mod m for PRIME m
long long int mod_inverse_Fermat(long long int x, long long int m);

// calculate x^n mod m
long long int fast_power(long long int x, long long int n, long long int m);

// extended euclid gojjohou
long long int euclid_extended(long long int a, long long int b, long long int &x, long long int &y);



int main(){
  
  long long int N, K, tmp;
  std::vector<long long int> A;
  
  scanf("%lld%lld", &N, &K);
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    A.push_back(tmp);
  }
  std::sort(A.begin(), A.end());

  /*std::cerr << "A: " << std::endl;
  for(long long int i = 0; i < N; i++){
    std::cerr << A[i] << " ";
  }std::cerr << std::endl;*/

  // make factorial table
  std::vector<long long int> fact_table(N+1);
  fact_table[0] = 1;
  for(long long int i = 1; i <= N; i++){
    fact_table[i] = mod(fact_table[i-1]*i, MOD);
  }

  // solve problem
  long long int ans = 0, nmin, nmax;
  for(long long int i = 0; i < N; i++){
    nmin = 0;
    nmax = 0;
    if(K-1 <= N-i-1){
      nmin = fact_table[N-i-1];
      nmin = mod(nmin * mod_inverse(fact_table[K-1], MOD), MOD);
      nmin = mod(nmin * mod_inverse(fact_table[N-i-K], MOD), MOD);
    }
    if(i >= K-1){
      nmax = fact_table[i];
      nmax = mod(nmax * mod_inverse(fact_table[K-1], MOD), MOD);
      nmax = mod(nmax * mod_inverse(fact_table[i-K+1], MOD), MOD);
    }
    //std::cerr << i << " " << nmin << " " << nmax << std::endl;
    ans += (nmax - nmin)*A[i];
    ans = mod(ans, MOD);
  }

  std::cerr << "Answer: " << std::endl;
  std::cout << ans << std::endl;

  return 0;
}


long long int mod(long long int x, long long int m){
  if(x>0){
    return x%m;
  }
  else if(x==0){
    return 0;
  }
  else if((-x)%m == 0){
    return 0;
  }
  else{
    return m - (-x)%m;
  }
}


long long int euclid_extended(long long int a, long long int b, long long int &x, long long int &y){
  long long int d = a;
  if(b != 0){
    d = euclid_extended(b, a%b, y, x);
    y -= (a/b)*x;
  }
  else{
    x = 1;
    y = 0;
  }
  
  return d;
}

long long int mod_inverse(long long int x, long long int m){
  long long int tmp, x_inv, gcd_xm;
  gcd_xm = euclid_extended(x, m, x_inv, tmp);
  // if the inverse is calculate properly
  if(gcd_xm == 1){
    return mod(x_inv, m);
  }
  else{
    //std::cerr << "Error in mod_inverse: there is no inverse of x in mod m" << std::endl;
    return 0;
  }
}

long long int mod_inverse_Fermat(long long int x, long long int m){
  return fast_power(x, m-2, m);
}

long long int fast_power(long long int x, long long int n, long long int m){
  long long int ans = 1;
  
  while(n > 0){
    if(n&1){
      ans = ans * x;
      ans = mod(ans, m);
    }
    x = x*x;
    x = mod(x, m);
    n = n>>1;
  }
  
  return ans;
}


Measured memory_bytes: 1908