#include <bits/stdc++.h>
using namespace std;
long long n, m[22][22] = {}, i, j, k, o, l = 0, z, sam = 0, p, q;
long long a[100005] = {}, inf = 1000000000000;
long long b[100005] = {};
string s[22];
long long t[100005], xx[100005];
char ss, st;
const int MAX = 100005;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  COMinit();
  for (int i = 0; i < n - k + 1; i++) {
    l += (COM(n - i - 1, k - 1) * a[i]) % MOD;
    l %= MOD;
  }
  for (i = k - 1; i < n; i++) {
    sam += (COM(i, k - 1) * a[i]) % MOD;
    sam %= MOD;
  }
  sam = (sam - l) % MOD;
  cout << sam;
  return 0;
}
