#include <bits/stdc++.h>
using namespace std;
using sint = int64_t;

sint const sint_min = numeric_limits<sint>::min();
sint const sint_max = numeric_limits<sint>::max();

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

template<class T> vector<T> read_vector(sint const n) {
	vector<T> vs;
	for (sint i = 0; i < n; ++i) {
		vs.push_back(read<T>());
	}
	return vs;
}

inline void write() {
}

template<class T> void write(T const& t) {
	cout << t;
}

template<class T> void write(vector<T> const& ts) {
	if (ts.size() > 0) {
		cout << ts[0];
	}
	for (size_t i = 1; i < ts.size(); ++i) {
		cout << ' ' << ts[i];
	}
}

template<class T, class... Args> void write(T const& t, Args const&... args) {
	cout << t << ' ';
	write(args...);
}

template<class... Args> void writeln(Args const&... args) {
	write(args...);
	cout << '\n';
}

inline sint gcd(sint y, sint x) {
	while (x != 0) {
		sint const t = y % x;
		y = x;
		x = t;
	}
	return y;
}

inline sint div_floor(sint const y, sint const x) {
	assert(x > 0);
	sint const r = y / x;
	return r * x <= y ? r : r - 1;
}

inline sint mod(sint const a, sint const p) {
	return a - p * div_floor(a, p);
}

template<class T>
T pow_int(T const a, sint const n) {
	if (n == 0) {
		return T(1);
	}
	T const h = pow_int(a, n / 2);
	T const f = h * h;
	return n % 2 == 1 ?  a * f : f;
}

template<sint P>
struct IntMod {
	explicit IntMod(sint m): n(mod(m, P)) {
	}

	explicit operator sint() const {
		return n;
	}

	sint n;
};

template<sint P>
IntMod<P> operator+(IntMod<P> lhs) {
	return IntMod<P>(+lhs.n);
}

template<sint P>
IntMod<P> operator-(IntMod<P> lhs) {
	return IntMod<P>(-lhs.n);
}

template<sint P>
IntMod<P> operator+(IntMod<P> lhs, IntMod<P> rhs) {
	return IntMod<P>(lhs.n + rhs.n);
}

template<sint P>
IntMod<P> operator-(IntMod<P> lhs, IntMod<P> rhs) {
	return IntMod<P>(lhs.n - rhs.n);
}

template<sint P>
IntMod<P> operator*(IntMod<P> lhs, IntMod<P> rhs) {
	return IntMod<P>(lhs.n * rhs.n);
}

template<sint P>
IntMod<P> operator/(IntMod<P> lhs, IntMod<P> rhs) {
	return lhs * pow_int(rhs, P - 2);
}

template<sint P>
struct FactorialMod {
	FactorialMod(sint const n) {
		IntMod<P> r(1);
		_table.push_back(r);
		for (sint i = 1; i < n; ++i) {
			r = r * IntMod<P>(i);
			_table.push_back(r);
		}
	}

	IntMod<P> factorial(sint const n) {
		assert(0 <= n && n < sint(_table.size()));
		return _table[n];
	}

	IntMod<P> combination(sint const n, sint const k) {
		return factorial(n) / (factorial(k) * factorial(n - k));
	}

private:
	vector<IntMod<P>> _table;
};

int main() {
	ios_base::sync_with_stdio(false);
	cin .exceptions(ios_base::badbit | ios_base::failbit);
	cout.exceptions(ios_base::badbit | ios_base::failbit);
	cin .tie(nullptr);
	cout.tie(nullptr);
	cout.precision(16);
	void run();
	run();
	return 0;
}

void run() {
	sint const MOD = 1000000007;
	auto const N = read<sint>();
	auto const K = read<sint>();
	auto As = read_vector<sint>(N);

	FactorialMod<MOD> fact_mod(N);

	sort(As.begin(), As.end());
	IntMod<MOD> sum_min(0);
	for (sint i = 1; i <= N - K + 1; ++i) {
		sum_min = sum_min + IntMod<MOD>(As[i - 1]) * fact_mod.combination(N - i, K - 1);
	}

	reverse(As.begin(), As.end());
	IntMod<MOD> sum_max(0);
	for (sint i = 1; i <= N - K + 1; ++i) {
		sum_max = sum_max + IntMod<MOD>(As[i - 1]) * fact_mod.combination(N - i, K - 1);
	}

	writeln(sint(sum_max - sum_min));
}

Measured memory_bytes: 2548