#include <bits/stdc++.h>

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REPB(i,n) for(long long i=((n)-1);i>=0;i--)
#define REPB1(i,n) for(long long i=(n);i>0;i--)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();ite++)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))


typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 1e5+5;
const int MOD = 1e9+7;
int N,K;

LL A[maxn];
LL inv[maxn];
LL fac[maxn];
LL facinv[maxn];
LL modpow(LL a, LL b){
    if(b==-1) return inv[a];
    if(b<-1) {
    a=inv[a%MOD];
    b*=-1;
    }
    if(b==0) return 1;
    if(b==1) return a%MOD;
    LL ret=modpow(a%MOD,b>>1)%MOD;
    return (ret*ret%MOD)*((b%2)?(a%MOD):1)%MOD;
}
LL fermat(LL a){
    if(a%MOD) return -1;
    return modpow(a,MOD-2);
}
inline LL modmult(LL a, LL b){
    return (a%MOD)*(b%MOD)%MOD;
}
inline LL modmult(LL a, LL b ,LL c){
    return (a%MOD)*(b%MOD)%MOD*(c%MOD)%MOD;
}
inline LL modfact(LL n){
    if(n==0 || n==1) return 1;
    if(n>=MOD) return 0;
    return fac[n];
}
inline LL modcomb(LL m, LL n){
    if(m>=MOD || n>=MOD || n<0 || m<0) return -1;
    if(n==0||n==m) return 1;
    if(m<n) return 0;
    return fac[m]*facinv[m-n]%MOD*facinv[n]%MOD;
}
void makelist(){
    inv[0]=-1;
    inv[1]=1;
    for(LL i=2;i<maxn;i++) inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
    fac[0]=1;
    REP1(i,maxn) fac[i]=(fac[i-1]*i)%MOD;
    facinv[maxn-1] = modpow(fac[maxn-1],MOD-2);
    REPB(i,maxn-1) facinv[i]=(facinv[i+1]*(i+1))%MOD;
}






int main()
{
    cin >> N >> K;
    _rep(i,1,N){
        cin >> A[i];
    }
    sort(A+1,A+N+1);
    makelist();
    LL ans = 0;

    _rep(i,1,N){
        int l = N-i;
        int r = K-1;
        if(l >= r){
            LL k = modcomb(l,r);
            LL k2 = -(k * A[i])%MOD;
            //cout << k << endl;
            ans = (ans + MOD + k2)%MOD;
        }
        l = i - 1;
        r = K - 1;
        if(l >= r){
            LL k = modcomb(l,r);
            LL k2 = (k*A[i])%MOD;
            //cout << A[i] << endl;
            ans = (ans+k2)%MOD;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328