// Slower C++ solution:
//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;

}

// Faster C++ solution for the same problem (measured speedup: 1.6927732649160256x):
#include <bits/stdc++.h>

using namespace std;

long long mod=1e9+7;



long long power(long long a, long long n, long long mod){

  long long res=1;

    while(n>0){

     if(n&1)

         res=(res*a)%mod;

     a=(a*a)%mod;

     n>>=1;

  }

return res;

}



long long inverse(long long a, long long mod){

  return power(a,mod-2,mod);

}



int main(){

  long long n,k,arr[100005];

  long long a[100005], b[100005];

  cin>>n>>k;

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

       cin>>arr[i];

  a[0]=1;

  b[0]=1;

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

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

    b[i]=inverse(a[i],mod);

  }

  sort(arr,arr+n);

  long long ans=0;

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

    long long x=1;

    x=(x*a[n-i-1])%mod;

    x=(x*b[k-1])%mod;

    x=(x*b[n-i-k])%mod;

    x=(arr[n-i-1]*x)%mod;

    ans=(ans+x+mod)%mod;

   }

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

    long long x=1;

    x=(x*a[n-1-i])%mod;

    x=(x*b[k-1])%mod;

    x=(x*b[n-i-k])%mod;

    x=(arr[i]*x)%mod;

    ans=(ans-x+mod)%mod;

  }

  cout<<ans<<endl;

}