#include <stdio.h>
#include <algorithm>
#define mod 1000000007
using namespace std;
typedef long long ll;

ll rev(ll a) {
  ll now = mod - 2, ans = 1;
  while(now) {
    if(now & 1) ans *= a, ans %= mod;
    a *= a, a %= mod, now >>= 1;
  }
  return ans;
}

int main(void) {
  ll i, j, k, n, ans = 0, now;
  scanf("%lld%lld", &n, &k);
  k--;
  ll a[n], fact[n + 1];
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  sort(a, a + n);
  fact[0] = 1;
  for(i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i, fact[i] %= mod;
  for(i = k; i < n; ++i) {
    now = fact[i] * rev(fact[k]), now %= mod;
    now *= rev(fact[i - k]), now %= mod;
    ans += a[i] * now, ans %= mod;
  }
  for(i = 0; i < n - k; ++i) {
    now = fact[n - i - 1] * rev(fact[k]), now %= mod;
    now *= rev(fact[n - i - k - 1]), now %= mod;
    ans -= a[i] * now, ans %= mod;
  }
  ans += mod;
  ans %= mod;
  printf("%lld", ans);
  return 0;
}