#include <iostream>
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;

using namespace std;

const ll mod = 1e9+7;

void Fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}


ll gcd(int a, int b){
    if(b==0)return a;
    return gcd(b,a%b);
}

void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll lcm(ll a, ll b){
    return (((a*b)%mod)*(fp(gcd(a,b), mod-2)))%mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}

int main()
{
    Fastio();
    calcFacAndInv(1e5+5);
    int n,k; cin>>n>>k;
    int arr[n];
    for(int i=0; i<n; i++){cin>>arr[i];}
    sort(arr,arr+n);
    ll res=0;
    for(int i=0; i<n; i++){
        if(i>=k-1)res+=(arr[i]*ncr(i,k-1));
        if(i+k-1<=n)res+=(-arr[i]*ncr(n-i-1,k-1));
        res%=mod;
    }
    cout<<res<<'\n';


    return 0;
}
