/*
 *Author - Abhas Jain
 *Code is inside the solve function
 */
 
#include <bits/stdc++.h>
 
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define endl '\n'
#define pb push_back
#define mp make_pair 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
 
typedef long long ll;
typedef long double ld;

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

 
using namespace std;
using namespace __gnu_pbds;
template <typename A, typename B>
string to_string(pair<A, B> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef AJ47
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
 
const ld PI = 3.141592653589793;
const ll INF = 9223372036854775807ll;
const ll mod = 1e9 + 7;
const int N = 1e5 + 2;

ll fact[N];
ll inv[N];

ll sub (ll a, ll b) {
	a -= b;
	if (a < 0) a += mod;
	return a;
}

ll add (ll a, ll b) {
	return ((a + b) % mod);
}

ll modinv(ll x) {
    ll ans = 1, ex = mod - 2;
    while (ex > 0) {
        if (ex & 1ll) {
            ans = (ans * x) % mod;
        }
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}


ll modncr (ll n, ll r) {
	if (n < r) return 0;
	ll ret = fact[n];
	ret *= inv[r];
	ret %= mod;
	ret *= inv[n - r];
	return (ret % mod);
}

void solve() 
{
    ll n, k;
    cin >> n >> k;
    ll pr = 0;
    vector<ll> a(n);
    fact[0] = 1;
    inv[0] = modinv(1);
    for (int i = 1; i <= n; ++i) {
    	fact[i] = fact[i - 1] * i;
    	fact[i] %= mod;
    	inv[i] = modinv(fact[i]);
    }
    for (int i = 0; i < n; ++i) {
    	cin >> a[i];
    }
    sort(all(a));
    for (int i = 0; i < n; ++i) {
    	pr = sub(pr, (a[i] * modncr(n - i - 1, k - 1)) % mod);
    	pr = add(pr, (a[i] * modncr(i, k - 1)) % mod);
    }
    cout << pr << endl;
}
 
int main( )
{   
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    solve();
    return 0;
}

Measured memory_bytes: 2560