#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

template<long long mod>
class modint{
	public:
		long long x;
		modint(long long a){x=a%mod;if(x<0)x+=mod;}
		modint(){x=0;}

		modint pow(long long a){
			modint res(1), b(x);
			while(a){
				if(a&1)res*=b;
				b*=b;
				a>>=1;
			}
			return res;
		}

		modint inv(){return pow(mod-2);}

		modint& operator+=(modint a){x=(x+a.x)%mod;return *this;}
		modint& operator-=(modint a){x=x-a.x;if(x<0)x+=mod;return *this;}
		modint& operator*=(modint a){x=x*a.x%mod;return *this;}
		modint& operator/=(modint a){x=x*a.inv().x%mod;return *this;}

		modint operator+(modint a){return modint(x)+=a;}
		modint operator-(modint a){return modint(x)-=a;}
		modint operator*(modint a){return modint(x)*=a;}
		modint operator/(modint a){return modint(x)/=a;}

		modint operator-(){return modint(x);}

		bool operator==(const modint a){return x == a.x;}
		bool operator<(const modint a){return x < a.x;}
		bool operator>(const modint a){return x > a.x;}
};

template<long long mod>
ostream& operator<<(ostream& os, const modint<mod>& a){
	os << a.x;
	return os;
}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

using mint = modint<(ll)1e9+7>;

mint factorial(int x){
	static vector<mint> memo;
	if(memo.empty()){
		memo.resize(1e5+5);
		memo[1] = 1;
		for(int i=1;i+1<1e5+5;++i){
			memo[i+1] = memo[i] * mint(i+1);
		}
	}
	if(x<=1)return mint(1);
	return memo[x];
}

mint C(int a,int b){
	if(b<0||a<0||a<b)return mint(0);
	return factorial(a) / factorial(a-b) / factorial(b);
}

int n;
int k;
mint func(map<int,int> m){
	int sum = n;
	mint ans(0);
	for(auto i=m.rbegin();i!=m.rend();++i){
		if(sum<k)break;
		int val = i->first;
		int num = i->second;
		repa(j,num+1){
			if(sum-j<0)break;
			if(k<j)break;
			ans += mint(val) * C(num,j) * C(sum-num,k-j);
		}
		sum -= num;
	}
	return ans;
}
int main(){
	cin >> n >> k;
	vector<mint> line(n);
	map<int,int> m;
	rep(i,n){
		int d;
		cin >> d;
		++m[d];
	}
	map<int,int> m2;
	foreach(i,m){
		m2[-i.first] += i.second;
	}
	
	cout << func(m) + func(m2) << endl;



	return 0;
}


Measured memory_bytes: 19200