// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define ms(x,y) memset(x, y, sizeof(x))

#define lowbit(x) ((x)&(-x))

#define sqr(x) ((x)*(x))

typedef long long LL;

typedef pair<int,int> pii;

typedef pair<LL,LL> pll;



const int maxn = 1e5+5;

const LL MOD = 1e9+7;



LL F[maxn], invF[maxn], inv[maxn];



void init() {

    inv[1] = 1;

    for(int i = 2; i < maxn; ++i)

        inv[i] = (MOD - MOD / i) * 1LL * inv[MOD % i] % MOD;

    F[0] = invF[0] = 1;

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

        F[i] = F[i-1] * 1LL* i % MOD;

        invF[i] = invF[i-1] * inv[i] % MOD;

    }

}



LL comb(int n, int m) {   // C(n, m)

    if(m < 0 || m > n) return 0;

    return F[n] * invF[n-m] % MOD * invF[m] % MOD;

}



void run_case() {

    init();

    int n, k;

    cin >> n >> k;

    vector<LL> a(n);

    LL ans = 0;

    for(auto &x: a) cin >> x;

    sort(a.begin(), a.end(), greater<LL>());

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

        (ans += comb(n-i-1, k-1)*a[i] % MOD) %= MOD;

    }

    sort(a.begin(), a.end());

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

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

    }

    cout << (ans + MOD) % MOD;

}





int main() {

    ios::sync_with_stdio(false), cin.tie(0);

    cout.flags(ios::fixed);cout.precision(9);

    //int t; cin >> t;

    //while(t--)

    run_case();

    cout.flush();

    return 0;

}

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

using namespace std;

#define endl '\n'

#define pb push_back

#define mp make_pair

#define SZ(x) ((int)(x).size())

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

#define mem0(s) memset(s,0,sizeof(s))

#define meminf(s) memset(s,0x3f,sizeof(s))

#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))

double pi=acos(-1);

typedef long long ll;

typedef unsigned long long ull;

inline ll lowbit(ll x){return x&(-x);}

inline ll min(ll a,ll b){return a<b?a:b;}

inline ll max(ll a,ll b){return a>b?a:b;}

const int INF=0x3f3f3f3f,max_n=100005,mod=1e9+7;

inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int a[max_n];

int jiecheng[100005]={1};

ll min1,max1;

long long inv(int i,int p)

{

	if(i==1)return 1;

	return (p-p/i)*inv(p%i,p)%p;

}

ll g(int n,int m,int p)

{

	int fenzi=jiecheng[n+m]%p;

	int fenmu=((ll)jiecheng[m]%p*jiecheng[n]%p)%p;

	ll niyuan=inv(fenmu,p);

	return (ll)fenzi*niyuan%p;

}

ll lucas(int n,int m,int p)

{

	if(n<0)

	{

		return 0;

	}

	if(n+m<=p)

	{

		return g(n,m,p);

	}

	if(m==0)return 1;

	if(m==1)return (n+m)%p;

	else if(n==0)return 1;

	else

	{

		int a1=lucas((n+m)/p-m/p,m/p,p)%p;

		int a2=lucas((n+m)%p-m%p,m%p,p)%p;

		return (ll)a1*a2%p;

	}

}

int main()

{

	for(int i=1;i<=100000;i++)

	{

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

	}

	int n,k;cin>>n>>k;

	for(int i=1;i<=n;i++)cin>>a[i];

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

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

	{

		min1=(min1+a[i]*lucas(k-1,n-i-k+1,mod))%mod;

	}

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

	{

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

	}

	cout<<((max1-min1)%mod+mod)%mod<<endl;

}

// Fastest known solution for this problem: