#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 2e18
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
 ll fac[100005];
// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}

// Returns nCr % p using Fermat's little
// theorem.
ll ncr(ll n, ll r, ll p)
{
          if(n<r){
                    return 0;
          }
   // Base case
   if (r==0)
      return 1;

    // Fill factorial array so that we
    // can find all factorial of r, n
    // and n-r


    return (fac[n]* modInverse(fac[r], p) % p *
            modInverse(fac[n-r], p) % p) % p;
}

// Driver program
int main()
{
    fac[0] = 1;
    for (ll i=1 ; i<100005; i++)
        fac[i] = (fac[i-1]*i)%mod;
          ll n,k;
          cin>>n>>k;
          vector<ll> a(n);
          arrin(a,n);
          sort(all(a));
          set<ll> s;
          map<ll,ll> mp;
          fri(i,0,n){
                    s.insert(a[i]);
          }
          fri(i,0,n){
                    mp[a[i]]++;
          }

          ll ans = 0;
          vector<ll> xxp;
          tra(it,s){
                    xxp.pb(*it);
          }
          tra(it,xxp){
                    vct :: iterator it1;
                    it1 = lower_bound(all(a),*it);
                    ll ss = it1-a.begin();
                    ll xx = 0;
                    fri(i,1,mp[*it]+1)
                    {
                              xx += (ncr(mp[*it],i,mod)*ncr(ss,k-i,mod))%mod;
                              xx %= mod;
                    }
                    xx *= *it;
                    xx %= mod;
                    ans += (xx);
                    ans %= mod;
                    it1 = upper_bound(all(a),*it);
                    ss = it1-a.begin();
                    ss = a.size()-ss;
                    xx = 0;
                    fri(i,1,mp[*it]+1)
                    {
                              xx += (ncr(mp[*it],i,mod)*ncr(ss,k-i,mod))%mod;
                              xx %= mod;
                    }
                    xx *= *it;
                    xx %= mod;
                    ans += (mod-xx)%mod;
                    ans %= mod;

          }
          cout<<ans<<endl;
}


Measured memory_bytes: 13052