#include <bits/stdc++.h>
using namespace std;
long long fac[100005];
long long infact[100005];
int power(int a, int b, int n) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y) % n;
    }
    y = (y * y) % n;
    b /= 2;
  }
  return x % n;
}
int modInverse(int n, int p) { return power(n, p - 2, p); }
int nCrModP(int n, int r, int p) {
  if (r == 0) return 1;
  return fac[n] * infact[r] * infact[n - r] % p;
}
int main() {
  int p = 1000000007;
  fac[0] = 1;
  infact[0] = 1;
  for (int i = 1; i <= 100001; i++) {
    fac[i] = (fac[i - 1] * i) % p;
    infact[i] = modInverse(fac[i], p);
  }
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int& i : a) cin >> i;
  sort(a.begin(), a.end());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cout << fac[i] << endl;
    if (i >= k - 1) {
      ans = (ans - ((nCrModP(i, k - 1, p) * a[i]) % p) + p) % p;
    }
    if (n - i - 1 >= k - 1)
      ans = (ans - (-((nCrModP(n - i - 1, k - 1, p) * a[i]) % p)) + p) % p;
  }
  cout << ans << '\n';
  return 0;
}
