///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

int n,k;
map<int,int>cnt;
vector<int>vec;
const int N = 1e5 + 100;
namespace Combi {
    int fact[N], inv[N];

    int bm(int b, int p, int m) {
        if(p == 0) return 1%m;
        int t = bm(b,p/2,m);
        t = (1ll*t*t)%m;
        if(p&1) return 1ll*t*b%m;
        return t;
    }

    int C(int n, int r) {
        if(n < 0 or r < 0 or r > n) return 0;
        int ret = 1ll*fact[n]*inv[r]%mod;
        ret = 1ll*ret*inv[n-r]%mod;
        return ret;
    }
    // X1 + X2 + ... + Xvar = Sum
    int no_of_eqns(int sum, int var) {
        return C(sum+var-1,var-1); // Xi >= 0
        // return C(sum-1,var-1); // Xi > 0
    }
    void init() {
        fact[0] = 1;
        for(int i = 1; i < N; i++) {
            fact[i] = 1ll*fact[i-1]*i%mod;
        }
        inv[N-1] = bm(fact[N-1], mod-2, mod);
        for(int i = N-2; i >= 0; i--) {
            inv[i] = 1ll*inv[i+1]*(i+1)%mod;
        }
    }
}
 main()

{
    fast
    Combi::init();
    cin>>n>>k;
    f(i,1,n)
    {
        int x;
        cin>>x;
        cnt[x]++;
    }
    for(auto x:cnt)
    {
        vec.pb(x.fi);
    }
    int sz=vec.size();
    vector<int>pre(sz+3,0),suf(sz+3,0);
    f(i,0,sz-1)
    {
        if(i!=0)pre[i]=pre[i-1];
        pre[i]+=cnt[vec[i]];
    }
    rf(i,sz-1,0)
    {
        suf[i]=suf[i+1]+cnt[vec[i]];
    }
    int ses=0;
    f(i,0,sz-1)
    {
        int mx=vec[i];
        int sml=0;
        if(i!=0)sml+=pre[i-1];
        sml+=cnt[mx];
        int way=0;
        for(int j=1;j<=cnt[mx];j++)
        {
            if(sml-j>=(k-1))
           {int val=Combi::C(sml-j,k-1);
            way=ad(way,val);}
            else break;
        }
        way=gun(way,mx);
        ses=ad(ses,way);
    }
    rf(i,sz-1,0)
    {
        int mn=vec[i];
        int big=suf[i+1];
        big+=cnt[mn];
        int way=0;
        for(int j=1;j<=cnt[mn];j++)
        {
            if(big-j>=(k-1))
            {
                 int val=Combi::C(big-j,k-1);
                 way=ad(way,val);
            }
            else break;
        }
        way=gun(way,mn);
        ses=sub(ses,way);
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 9972