// Original C++ solution (slower):
#include <bits/stdc++.h>

#include<algorithm>

#define int long long

using namespace std;

typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define INF 1000000000000



int MOD=1000000007;

int vector_finder(std::vector<int> vec, int number) {

  auto itr = std::find(vec.begin(), vec.end(), number);

  size_t index = std::distance( vec.begin(), itr );

  if (index != vec.size()) { // 発見できたとき

    return 1;

  }

  else { // 発見できなかったとき

    return 0;

  }

}

int modpow(int a,int x){

  if(a<0)a+=MOD;

  int ans=1;

  while(x>0){

    if(x&1) ans=ans*a%MOD;

      a=a*a%MOD;

      x>>=1;

  }

  return ans;

}

int gyaku(int n){

    return modpow(n,MOD-2);

}

signed main() {

int n,k;

cin>>n>>k;

vector<int>a(n);

rep(i,n)cin>>a[i];

sort(a.begin(),a.end());

//combmaekeisan

vector<int>kai(100002);

kai[0]=1;

rep(i,100001){

  kai[i+1]=(i+1)*kai[i]%MOD;

}

//suuretunowa

vector<int>s(n-k+2);

for(int i=k;i<=n;i++){

  s[i+1-k]=(s[i-k]+(kai[i-2]*gyaku(kai[k-2]))%MOD*gyaku(kai[i-k])%MOD)%MOD;

}

int ans=0;

//tasu

for(int i=n-1;i>=k-1;i--){

  ans=(ans+s[i-k+2]*a[i]%MOD)%MOD;

  while(ans<0)ans+=MOD;

}

//hiku

for(int i=0;i<=n-k;i++){

  ans=(ans-s[n-k-i+1]*a[i]%MOD)%MOD;

  while(ans<0)ans+=MOD;

}



cout<<ans<<endl;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#include<algorithm>

#define int long long

using namespace std;

typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define INF 1000000000000



template<int MOD> struct Fp {

    long long val;

    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {

        if (val < 0) val += MOD;

    }

    constexpr int getmod() { return MOD; }

    constexpr Fp operator - () const noexcept {

        return val ? MOD - val : 0;

    }

    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }

    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }

    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }

    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }

    constexpr Fp& operator += (const Fp& r) noexcept {

        val += r.val;

        if (val >= MOD) val -= MOD;

        return *this;

    }

    constexpr Fp& operator -= (const Fp& r) noexcept {

        val -= r.val;

        if (val < 0) val += MOD;

        return *this;

    }

    constexpr Fp& operator *= (const Fp& r) noexcept {

        val = val * r.val % MOD;

        return *this;

    }

    constexpr Fp& operator /= (const Fp& r) noexcept {

        long long a = r.val, b = MOD, u = 1, v = 0;

        while (b) {

            long long t = a / b;

            a -= t * b; swap(a, b);

            u -= t * v; swap(u, v);

        }

        val = val * u % MOD;

        if (val < 0) val += MOD;

        return *this;

    }

    constexpr bool operator == (const Fp& r) const noexcept {

        return this->val == r.val;

    }

    constexpr bool operator != (const Fp& r) const noexcept {

        return this->val != r.val;

    }

    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {

        return os << x.val;

    }

    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {

        if (n == 0) return 1;

        auto t = modpow(a, n / 2);

        t = t * t;

        if (n & 1) t = t * a;

        return t;

    }

};





const int MOD = 1000000007;

using mint = Fp<MOD>;





int modpow(int a,int x){

  if(a<0)a+=MOD;

  int ans=1;

  while(x>0){

    if(x&1) ans=ans*a%MOD;

      a=a*a%MOD;

      x>>=1;

  }

  return ans;

}

int gyaku(int n){

    return modpow(n,MOD-2);

}



////////////////////////////////////////////////////////////////////////

signed main() {

  int n,k;

  cin>>n>>k;

  vector<int>a(n);

  rep(i,n)cin>>a[i];

  sort(a.begin(),a.end());

  //combmaekeisan

  vector<int>kai(100002);

  kai[0]=1;

  rep(i,100001){

    kai[i+1]=(i+1)*kai[i]%MOD;

  }

  //suuretunowa

  vector<mint>s(n-k+2);

  for(int i=k;i<=n;i++){

    s[i+1-k]=(s[i-k]+((mint)kai[i-2]*(mint)gyaku(kai[k-2]))*(mint)gyaku(kai[i-k]));

  }

  mint ans=0;

  //tasu

  for(int i=n-1;i>=k-1;i--){

    ans=ans+s[i-k+2]*(mint)a[i];

  }

  //hiku

  for(int i=0;i<=n-k;i++){

    ans=ans-s[n-k-i+1]*(mint)a[i];

  }



  cout<<ans<<endl;

}


// Fastest known solution for this problem: