def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    mod = 10**9+7

    fact = [1]

    for i in range(1, n+1):
        fact.append(fact[-1]*i % mod)

    def inv_n(n, mod=10**9+7): return pow(n, mod-2, mod)
    def nCr(n, r, mod=10**9+7): return inv_n(fact[n-r]
                                             * fact[r] % mod, mod)*fact[n] % mod

    ans = 0

    for i in range(n-k+1):
        ans = (ans+nCr(n-i-1, k-1)*(a[n-i-1]-a[i])) % mod
    print(ans)


main()
