#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long combination(int n, int k) {
  static const int maxi = 1e6 + 1;
  static vector<long long> fac(maxi, 0), finv(maxi, 0), inv(maxi, 0);
  static const int mod = 1e9 + 7;
  if (fac[0] == 0) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < maxi; 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;
    }
  }
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main() {
  int N, K;
  cin >> N >> K;
  vector<long long> As(N);
  for (int i = 0, i_len = (N); i < i_len; ++i) cin >> As[i];
  sort((As).begin(), (As).end());
  long long sum_maxS = 0;
  for (int i = (K - 1); i < (N); ++i) {
    sum_maxS += As[i] * combination(i, K - 1);
    sum_maxS %= long long(1e9 + 7);
  }
  long long sum_minS = 0;
  for (int i = 0, i_len = (N - (K - 1)); i < i_len; ++i) {
    sum_minS += As[i] * combination(N - (i + 1), K - 1);
    sum_minS %= long long(1e9 + 7);
  }
  long long ans = sum_maxS - sum_minS < 0
                      ? (sum_maxS - sum_minS) + (long long)1e9 + 7
                      : sum_maxS - sum_minS;
  cout << ans << endl;
  return 0;
}
