#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}


long long mod = 1e9 + 7;

inline long long binpow_modulo(long long x, long long n)
{
	long long p = 1;
	while (n)
	{
		if (n % 2)
		{
			p = (p%mod)*(x%mod) % mod;
			n--;
		}
		x = (x%mod)*(x%mod) % mod;
		n /= 2;
	}
	return p % mod;
}

struct modint
{
	long long val;
	modint(long long x)
	{
		val = (x+mod*mod)%mod;
	}
	modint()
	{
		val = 0;
	}

	// operator = (done by standart)

	//operator +=
	modint operator+=(const modint &a)
	{
		val = (val%mod + a.val%mod) % mod;
		return *this;
	}
	modint operator+=(const int &a)
	{
		val = (val%mod + a % mod) % mod;
		return *this;
	}
	modint operator+=(const long long &a)
	{
		val = (val%mod + a % mod) % mod;
		return *this;
	}

	//operator -=
	modint operator-=(const modint &a)
	{
		val = (val%mod - a.val%mod+mod) % mod;
		return *this;
	}
	modint operator-=(const int &a)
	{
		val = (val%mod - a % mod+mod*mod) % mod;
		return *this;
	}
	modint operator-=(const long long &a)
	{
		val = (val%mod - a % mod+mod*mod) % mod;
		return *this;
	}

	//operator *=
	modint operator*=(const modint&a)
	{
		val = (val%mod)*(a.val%mod) % mod;
		return *this;
	}
	modint operator*=(const int &a)
	{
		val = (val%mod)*(a%mod) % mod;
		return *this;
	}
	modint operator*=(const long long &a)
	{
		val = (val%mod)*(a%mod) % mod;
		return *this;
	}
	
	//operator /=
	modint operator/=(const modint&a)
	{
		long long obr = binpow_modulo(a.val, mod - 2);
		val = (val%mod)*(obr%mod) % mod;
		return *this;
	}
	modint operator/=(const int&a)
	{
		long long obr = binpow_modulo(a, mod - 2);
		val = (val%mod)*(obr%mod) % mod;
		return *this;
	}
	modint operator/=(const long long &a)
	{
		long long obr = binpow_modulo(a, mod - 2);
		val = (val%mod)*(obr%mod) % mod;
		return *this;
	}

};

//output
ostream& operator<< (ostream& os, modint const& x) 
{
	os << x.val;
	return os;
}

//operator +
modint operator+(const modint&a, const modint&b)
{
	return modint((a.val%mod + b.val%mod) % mod);
}
modint operator+(const modint&a, const int &b)
{
	return modint((a.val%mod + b%mod) % mod);
}
modint operator+(const modint&a, const long long &b)
{
	return modint((a.val%mod + b % mod) % mod);
}

//operator -
modint operator-(const modint&a, const modint &b)
{
	return modint((a.val%mod - b.val%mod + mod*mod) % mod);
}
modint operator-(const modint &a, const int &b)
{
	return modint((a.val%mod - b % mod + mod*mod) % mod);
}
modint operator-(const modint &a, const long long &b)
{
	return modint((a.val%mod - b % mod + mod*mod) % mod);
}

//operator *
modint operator*(const modint&a, const modint&b)
{
	return modint(((a.val%mod)*(b.val%mod)) % mod);
}
modint operator*(const modint&a, const int&b)
{
	return modint(((a.val%mod)*(b%mod)) % mod);
}
modint operator*(const modint&a, const long long&b)
{
	return modint(((a.val%mod)*(b%mod)) % mod);
}

//opertor / (for know just by prime modulo)
modint operator/(const modint&a, const modint&b)
{
	long long obr = binpow_modulo(b.val, mod - 2);
	return a * obr;
}
modint operator/(const modint&a, int &b)
{
	long long obr = binpow_modulo(b, mod - 2);
	return a * obr;
}
modint operator/(const modint&a, long long &b)
{
	long long obr = binpow_modulo(b, mod - 2);
	return a * obr;
}

modint f[100000 + 1010];

modint C(ll n, ll k)
{
	return f[n] / f[k] / f[n - k];
}

void solve()
{

	f[0] = 1;
	for (ll i = 1; i < 100000 + 1010; i++)
		f[i] = f[i - 1] * i;

	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	input(a);

	if (k == 1)
	{
		cout << 0;
		return;
	}

	modint sum_min = 0, sum_max = 0;

	sort(all(a));

	for (int i = 0; i <= n - k; i++)
		sum_min+=a[i]*C(n - i - 1, k - 1);

	for (int i = n - 1; i >= k - 1; i--)
		sum_max+=a[i]*C(i, k - 1);

	cout << sum_max - sum_min;

}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();

}

Measured memory_bytes: 1792