#include <bits/stdc++.h>
using namespace std;
#define N 100005
#define MOD 1000000007
int n,m,ans,a[N],b[N],fc[N],invF[N];
bool cmp(int x,int y) {return a[x]==a[y]?x<y:a[x]<a[y];}
int inv(int x) {return x==1?1:1ll*inv(MOD%x)*(MOD-MOD/x)%MOD;}
int C(int x,int y) {return x<y?0:1ll*fc[x]*invF[y]%MOD*invF[x-y]%MOD;} 
int main()
{
	fc[0]=invF[0]=1;scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i) b[i]=i,scanf("%d",&a[i]);sort(b+1,b+n+1,cmp);
	for(int i=1;i<=n;++i) fc[i]=1ll*fc[i-1]*i%MOD;invF[n]=inv(fc[n]);
	for(int i=n-1;i>=1;--i) invF[i]=1ll*invF[i+1]*(i+1)%MOD;
	for(int i=1;i<=n;++i) ans=(ans+(1ll*(C(i-1,m-1)-C(n-i,m-1))*a[b[i]]%MOD))%MOD;
	printf("%d\n",ans);return 0;
}