//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

struct Mod {
	static ll gcd(ll x, ll y, ll* out_cx, ll* out_cy) {
		if (x < 0) {
			ll d = gcd(-x, y, out_cx, out_cy);
			if (out_cx) {
				*out_cx *= -1;
			}
			return d;
		}
		if (y < 0) {
			ll d = gcd(x, -y, out_cx, out_cy);
			if (out_cy) {
				*out_cy *= -1;
			}
			return d;
		}
		if (x > y) {
			return gcd(y, x, out_cy, out_cx);
		}
		if (x == 0) {
			if (out_cx && out_cy) {
				*out_cx = 0;
				*out_cy = 1;
			}
			return y;
		}
		ll q = y / x;
		ll r = y % x;
		ll d = gcd(r, x, out_cy, out_cx);
		if (out_cx) {
			*out_cx -= q * *out_cy;
		}
		return d;
	}
	static ll BASE;
	ll value = 0;
	static ll residue(ll value) { return (value % BASE + BASE) % BASE; }
	Mod()
	: value(0) {}
	Mod(ll value)
	: value(residue(value)) {}
	Mod operator+(const Mod& rhs) const { return Mod(value + rhs.value); }
	void operator+=(const Mod& rhs) { *this = *this + rhs; }
	Mod operator-(const Mod& rhs) const { return Mod(value - rhs.value); }
	void operator-=(const Mod& rhs) { *this = *this - rhs; }
	Mod operator*(const Mod& rhs) const { return Mod(value * rhs.value); }
	void operator*=(const Mod& rhs) { *this = *this * rhs; }
	Mod operator/(const Mod& rhs) const { return *this * rhs.inv(); }
	void operator/=(const Mod& rhs) { *this = *this / rhs; }
	Mod inv() const {
		if (value == 0) {
			assert(false);
			throw "[Mod::inv] div by zero";
		}
		ll ans, sub;
		ll d = Mod::gcd(value, BASE, &ans, &sub);
		if (d != 1) {
			assert(false);
			throw "[Mod::inv] not invertible";
		}
		return ans;
	}
};
ll Mod::BASE = 1000000007;

int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> As(N);
	rep(i,0,N) {
		cin >> As[i];
	}
	sort(As.begin(), As.end());
	vector<Mod> fact(N+1, 1);
	rep(n,1,N+1) {
		fact[n] = fact[n-1] * n;
	}
	auto binom = [&fact](ll n, ll r) -> Mod {
		if (0 <= r && r <= n) {
			return fact[n] / fact[r] / fact[n-r];
		} else {
			return 0;
		}
	};
	Mod max_sum = 0;
	Mod min_sum = 0;
	set<ll> numbers(As.begin(), As.end());
	for (ll a : numbers) {
		ll n1 = distance(As.begin(), upper_bound(As.begin(), As.end(), a));
		ll n2 = distance(As.begin(), lower_bound(As.begin(), As.end(), a));
		// cout << "a: " << a << ", max cases: " << (binom(n1, K) - binom(n2, K)).value << endl;
		max_sum += (binom(n1, K) - binom(n2, K)) * a;
		n1 = distance(lower_bound(As.begin(), As.end(), a), As.end());
		n2 = distance(upper_bound(As.begin(), As.end(), a), As.end());
		min_sum += (binom(n1, K) - binom(n2, K)) * a;
		// cout << "a: " << a << ", min cases: " << (binom(n1, K) - binom(n2, K)).value << endl;
	}
	Mod ans = max_sum - min_sum;
	cout << ans.value << endl;
}

Measured memory_bytes: 6016