#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;

template<int mod> struct ModInt {
	int val;
	constexpr ModInt(int v = 0) noexcept : val(v % mod) {
		if (val < 0) val += mod;
	}
	constexpr int getmod() { return mod; }
	constexpr ModInt operator - () const noexcept {
		return val ? mod - val : 0;
	}
	constexpr ModInt operator + (const ModInt& r) const noexcept { return ModInt(*this) += r; }
	constexpr ModInt operator - (const ModInt& r) const noexcept { return ModInt(*this) -= r; }
	constexpr ModInt operator * (const ModInt& r) const noexcept { return ModInt(*this) *= r; }
	constexpr ModInt operator / (const ModInt& r) const noexcept { return ModInt(*this) /= r; }
	constexpr ModInt& operator += (const ModInt& r) noexcept {
		val += r.val;
		if (val >= mod) val -= mod;
		return *this;
	}
	constexpr ModInt& operator -= (const ModInt& r) noexcept {
		val -= r.val;
		if (val < 0) val += mod;
		return *this;
	}
	constexpr ModInt& operator *= (const ModInt& r) noexcept {
		val = val * r.val % mod;
		return *this;
	}
	constexpr ModInt& operator /= (const ModInt& r) noexcept {
		int a = r.val, b = mod, u = 1, v = 0;
		while (b) {
			int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % mod;
		if (val < 0) val += mod;
		return *this;
	}
	constexpr bool operator == (const ModInt& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const ModInt& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream &os, const ModInt<mod>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream &is, ModInt<mod>& x) noexcept {
		return is >> x.val;
	}
	friend constexpr ModInt<mod> modpow(const ModInt<mod> &a, int n) noexcept {
		if (n == 0) return 1;
		auto t = modpow(a, n / 2);
		t = t * t;
		if (n & 1) t = t * a;
		return t;
	}
};
template<class T> struct BiCoef {
	vector<T> fact_, inv_, finv_;
	constexpr BiCoef() {}
	constexpr BiCoef(int n) noexcept : fact_(n, 1), inv_(n, 1), finv_(n, 1) {
		init(n);
	}
	constexpr void init(int n) noexcept {
		fact_.assign(n, 1), inv_.assign(n, 1), finv_.assign(n, 1);
		for (int i = 2; i < n; i++) {
			fact_[i] = fact_[i - 1] * i;
			inv_[i] = -inv_[MOD%i] * (MOD / i);
			finv_[i] = finv_[i - 1] * inv_[i];
		}
	}
	constexpr T comb(int n, int k) const noexcept {
		if (n < k || n < 0 || k < 0) return 0;
		return fact_[n] * finv_[k] * finv_[n - k];
	}
	constexpr T fact(int n) const noexcept {
		if (n < 0) return 0;
		return fact_[n];
	}
	constexpr T inv(int n) const noexcept {
		if (n < 0) return 0;
		return inv_[n];
	}
	constexpr T finv(int n) const noexcept {
		if (n < 0) return 0;
		return finv_[n];
	}
};

BiCoef<ModInt<MOD>> bc;

signed main() {
  bc.init(200000);

  int N, K;
  cin >> N >> K;

  vector<int> A(N);
  REP(i, N) cin >> A[i];
  sort(ALL(A));

  ModInt<MOD> ans = 0;
  ModInt<MOD> tmp;
  REP(i, N){
    tmp = A[i];
    ans += tmp*bc.comb(i, K-1);
    ans -= tmp*bc.comb(N-i-1, K-1);
  }

  cout << ans << endl;
   

  return 0;
}

Measured memory_bytes: 5760