#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
using namespace std;
 
#define int                 long long int
#define ull                 unsigned int
#define ld                  long double
#define pb                  push_back
#define ff                  first
#define ss                  second
#define S(arr)              sort(arr.begin(),arr.end());
#define RS(arr)              sort(arr.rbegin(),arr.rend());
#define R(arr)              reverse(arr.begin(),arr.end());
#define si                  set <int>
#define vi                  vector <int>
#define vvi                 vector <vector <int>>
#define vs                  vector <string>
#define mp                  make_pair
#define pii                 pair <int, int>
#define vpi                 vector <pii>
#define vpp                 vector <pair<int, pii>>
#define mii                 map <int, int>
#define mci                 map<char, int>
#define mpi                 map <pii, int>
#define spi                 set <pii>
#define speed               ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl                "\n"
#define all(p)              p.begin(), p.end()
#define T                   int tcf;cin>>tcf;while(tcf--)
#define que_max(t)             priority_queue <t>
#define que_min(t)             priority_queue <t, vector<t>, greater<t>>
#define debuga(a, l, r)     for(auto x:a)cout<<x<<" ";cout<<endl;
#define debug1(x)           cout << #x " = " << x << endl;
#define debug2(x,y)         cout << #x " = " << x << " " << #y " = " << y << endl;
#define debug3(x,y,z)       cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define debug4(x,y,z,w)     cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << endl;
#define debug5(x,y,z,w,v)   cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << " " << #v " = " << v << endl;
#define debug6(x,y,z,w,v,a) debug3(a, y, x)debug3(w, v, a)
#define p2d(v)          for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)              for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppi(v)  for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
 
 
void read(int n=10){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<setprecision(n)<<fixed;
    // #ifndef ONLINE_JUDGE
    //      freopen("input.txt",  "r",  stdin);
    //      freopen("output.txt", "w", stdout);
    // #endif
}
 
int M = 1e9 + 7;
int M1 = 998244353;
#define qqq 1000005
 
vi fact;
vi factinv;
void fac(int n=qqq){
    fact.resize(n+1);
    fact[0]=fact[1]=1;
    for(int i=2;i<=n;i++) fact[i]=(fact[i-1]*i)%M;
}
int powerM(int a,int b,int m = M){
    int ans = 1;
    while(b){
        int lb = (b&1);
        if(lb)    ans = (ans*a)%M;
        a = (a*a)%M;  b = b>>1;  
    }    return ans;
}
 
int32_t main(){
    read();fac();
    for(int i=0;i<qqq;i++)
        factinv.pb(powerM(fact[i],M-2));
    int n,k;
    cin>>n>>k;
    vi arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    S(arr);
    int sum = 0,s=0;;
    for(int i=k-1;i<n;i++){
        int temp = (arr[i]*fact[i])%M;
        temp = (temp * factinv[i-(k-1)])%M;
        temp = (temp * factinv[k-1])%M;
        sum = (sum+temp)%M;
    }
    R(arr);
    for(int i=k-1;i<n;i++){
        int temp = (arr[i]*fact[i])%M;
        temp = (temp * factinv[i-(k-1)])%M;
        temp = (temp * factinv[k-1])%M;
        s = (s+temp)%M;
    }
    cout<<(sum-s)%M<<endl;
}

Measured memory_bytes: 18284