#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <fstream>
#include <list>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <ctime>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define _DEBUG
#define vec vector
#define pb push_back
#define en '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<ll, ll> pull;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef long double ld;
typedef unsigned int ui;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vi2;
typedef vector<vector<ll>> vll2;
typedef vector<vector<ll>> matrix;
typedef vec<vec<vec<int>>> vi3;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define for1(i,n) for(int i = 1;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define REP(a,i,b) for (int i = a;i<b;i++);

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

const int inf = 2000000000;
const ll linf = 5000000000000000000;
const ld LDINF = 2e18;
template<typename T> void print(vector<T>& a)
{
    for (int i = 0; i < a.size(); i++)
        cout << a[i] << ' ';
    cout << en;
}

template<typename T> void print(deque<T>& a)
{
    for (int i = 0; i < a.size(); i++)
        cout << a[i] << ' ';
    cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
    for (int i = 0; i < a.size(); i++)
    {
        for (int j = 0; j < a[i].size(); j++)
            cout << a[i][j] << ' ';
        cout << en;
    }
}

template <typename T> void input(vector<T>& a)
{
    for (int i = 0; i < a.size(); i++)
        cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
    for (int i = 0; i < a.size(); i++)
        cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
    for (int i = 0; i < a.size(); i++)
        for (int j = 0; j < a[i].size(); j++)
            cin >> a[i][j];
}

ll mod = 1e9 + 7;

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

ll BinPow(ll a, ll n){
    if(n == 0)
        return 1;
    if(n % 2 == 0){
        ll val = BinPow(a, n/2);
        return val * val % mod;
    }
    else{
        ll val = BinPow(a, n-1);
        return val * a % mod;
    }
}

vec<ll> fact;

ll C(ll n, ll k){
    if(n < k)
        return 0;
    ll val = fact[n];
    val *= BinPow(fact[k], mod-2);
    val %= mod;
    val *= BinPow(fact[n-k], mod-2);
    val %= mod;
    return val;
}


void solve(){
    fact = vec<ll>(100001);
    ll n, k;
    cin >> n >> k;
    vec<ll> a(n);
    input(a);
    sort(all(a));
    fact[0] = 1;
    for(int i = 1; i <= 100001; i++){
        fact[i] = fact[i-1] * i % mod;
    }
    
    ll plus = 0, minus =0;
    for(int i = 0; i < n; i++){
        ll nown = n - i - 1;
        ll nowk = k-1;
        ll c = C(nown, nowk);
        minus += c*a[i];
        minus += mod * mod;
        minus %= mod;
    }
    
    reverse(all(a));
    
    for(int i = 0; i < n; i++){
        ll nown = n - i - 1;
        ll nowk = k-1;
        ll c = C(nown, nowk);
        plus += c*a[i];
        plus += mod * mod;
        plus %= mod;
    }
    
    cout << (plus - minus + mod)%mod;
    
}

int main()
{
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
    freopen("input.txt", "r", stdin);
#endif
    // freopen("graph.in", "r", stdin);
    // freopen("graph.out", "w", stdout);
    
    int tst = 1;
   // cin >> tst;
    while(tst--)
        solve();
}





Measured memory_bytes: 1792