// Original C++ solution (slower):
//bismillahir rahmanir rahim            //Author:Fayed Anik

 

#include <bits/stdc++.h>

//#include <ext/pb_ds/assoc_container.hpp>

//#include <ext/pb_ds/tree_policy.hpp>

 

using namespace std;

//using namespace __gnu_pbds;

 

/*

template <typename T>  using ordered_set =

    tree<T, null_type, less<T>,   /// greater<T> for sorting decreasingly

    rb_tree_tag, tree_order_statistics_node_update>;

*/



#define         ll                          long  long

#define         lf                          double

#define         pb(x)                       push_back(x)

#define         ull                         unsigned long long

#define         sfl(a)                      scanf("%lld",&a)

#define         sf(a)                       scanf("%d",&a)

#define         pf(a)                       printf("%d\n",a)

#define         pfl(a)                      printf("%lld\n",a)

#define         FOR(x,n)                    for(ll x=1;x<=n;++x)

#define         pii                         pair< ll , ll >

#define         mp(a,b)                     make_pair(a,b)

#define         mod                         1000000007

#define         INF                         2e18

#define         f1                          first

#define         f2                          second

#define         all(v)                      v.begin(),v.end()

#define         PI                          acos(-1)

#define         printminusone               printf("-1\n")

#define         bug                         printf("bug")

#define         FILEIN                      freopen("in.txt","r",stdin)

#define         FILEOUT                     freopen("out.txt","w",stdout)

 

//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }

//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }

//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }

//priority_queue <ll, vector<ll>, greater<ll> > pq;



#define N 100005



ll fac[N],inv[N],a[N];



ll fastexpo(ll b,ll p){

    ll res=1;

    while(p){

        if(p&1){

            res = (res * b)%mod;

        }

        p=p>>1ll;

        b=(b*b)%mod;

    }

    return res;

}



ll NCR(ll n,ll r){

    if(n==r or r==0) return 1;

    ll val = fac[n];

    val = (val * fastexpo(fac[n-r],mod-2))%mod;

    val = (val * fastexpo(fac[r],mod-2))%mod;

    return val;

}

int main(){

    fac[0]=1;

    for(ll i=1;i<=100000;i++){

        fac[i]=(fac[i-1]*i)%mod;

    }

    ll n,k;

    //cout << NCR(5,2) << endl;

    sfl(n),sfl(k);

    for(ll i=1;i<=n;i++){

        sfl(a[i]);

    }

    sort(a+1,a+n+1);

    ll ans = 0;

    for(ll i=1;i<=n;i++){

        if(i-1>=k-1){

            ans += (NCR(i-1,k-1)*a[i])%mod;

            ans %= mod;

        }

        if(n-i>=k-1){

            ans -= (NCR(n-i,k-1)*a[i])%mod;

            (ans += mod)%=mod;

        }

    }

    pfl(ans);

    return 0;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

#define ll long long



ll a[100009], mod = 1e9+7;



ll bigmod(ll b, ll p)

{

    if(p == 0)

        return 1;

    ll x = 1, y;

    if(p&1)

        x = b%mod;

    y = bigmod(b, p>>1);

    return ((y*y)%mod*x)%mod;

}







int main()

{

    ll n, k, i, j;

    cin >> n >> k;

    for(i = 0; i < n; i++)

        cin >> a[i];

    sort(a, a+n);

    ll p = 1, ans = a[k-1] - a[n-k];

    for(i = k; i <= n-1; i++)

    {

        p = (p*(i*bigmod(i-k+1, mod-2)%mod))%mod;

        ans = (ans + p*(a[i] - a[n - i - 1])%mod)%mod;

    }



    cout << (ans + mod)%mod;

}


// Fastest known solution for this problem: