#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1000000007;

ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a) { return (a % mod + mod) % mod; }

inline ll add(ll a, ll b) { return take_mod(a + b); }

inline ll sub(ll a, ll b) { return take_mod(a - b); }

inline ll mul(ll a, ll b) { return take_mod(a * b); }

inline ll pow(ll x, ll n) {
  ll res = 1LL;
  while (n > 0) {
    if (n & 1) res = mul(res, x);
    x = mul(x, x);
    n >>= 1;
  }
  return res;
}

ll mod_inv(ll x) { return pow(x, mod - 2); }

void make_fact(ll n) {
  fact[0] = 1;
  ll res = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = res;
    res = mul(res, i + 1);
  }
}

void make_invfact(ll n) {
  invfact[0] = 1;
  invfact[n] = mod_inv(fact[n]);
  for (int i = n - 1; i >= 1; i--) {
    invfact[i] = mul(invfact[i + 1], i + 1);
  }
}

ll perm(ll n, ll k) { return mul(fact[n], invfact[n - k]); }

ll comb(ll n, ll k) { return mul(mul(fact[n], invfact[n - k]), invfact[k]); }

int main() {
  ll n, k;
  cin >> n >> k;

  map<ll, ll> st;
  map<ll, ll> Ms;
  map<ll, ll> ms;

  rep(i, n) {
    ll t;
    cin >> t;
    st[t]++;
  }

  ll pre = 0;
  for (auto kv : st) {
    Ms[kv.first] = pre;
    pre = Ms[kv.first] + st[kv.first];
  }
  pre = 0;
  for (auto it = st.rbegin(); it != st.rend(); ++it) {
    ms[it->first] = pre;
    pre = ms[it->first] + st[it->first];
  }

  ll ans = 0;

  make_fact(200000);
  make_invfact(200000);

  for (auto kv : st) {
    ll t = kv.first;
    ll c = kv.second;
    ll addv = 0;
    ll ch;
    ch = Ms[t] + c;
    if (ch >= k) {
      addv = comb(ch, k);
      if (Ms[t] >= k) {
        ll x = comb(Ms[t], k);
        addv = sub(addv, x);
      }
      if (c >= k) {
        ll x = comb(c, k);
        addv = sub(addv, x);
      }
      addv = mul(t, addv);
    }
    ans = add(ans, addv);

    addv = 0;
    ch = ms[t] + c;
    if (ch >= k) {
      addv = comb(ch, k);
      if (ms[t] >= k) {
        ll x = comb(ms[t], k);
        addv = sub(addv, x);
      }
      if (c >= k) {
        ll x = comb(c, k);
        addv = sub(addv, x);
      }
      addv = mul(t, addv);
    }    
    //ans = sub(ans, addv);
    ans -= addv;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 20864