N, K = list(map(int, input().split()))

A = list(map(int, input().split()))

A = sorted(A)

p = 1000000007

frac = [1]

for i in range(N):

  frac.append(frac[i]*(i+1)%p)



def power(n, r, mod):

    if r == 0: return 1

    if r%2 == 0:

        return power(n*n % mod, r//2, mod) % mod

    if r%2 == 1:

        return n * power(n, r-1, mod) % mod



def comb(n, k, mod):

    a=frac[n]

    b=frac[k]

    c=frac[n-k]

    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

  



ans = 0  

for i in range(N- K +1):

  ans += ((A[N-1-i] - A[i])*comb(N-1-i, K-1, p))

  ans = ans % p

print(ans)
N, K = list(map(int, input().split()))

A = list(map(int, input().split()))

A = sorted(A)

p = 1000000007

frac = [1]



for i in range(N):

  frac.append(frac[i]*(i+1)%p)



def comb(n, k, mod):

    a=frac[n]

    b=frac[k]

    c=frac[n-k]

    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod

  

ans = 0  

for i in range(N- K +1):

  ans += ((A[N-1-i] - A[i])*comb(N-1-i, K-1, p))

  ans = ans % p

print(ans)
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A = sorted(A)
p = 1000000007
frac = [1]
for i in range(N):
    frac.append(frac[i] * (i + 1) % p)


def power(n, r, mod):
    if r == 0:
        return 1
    if r % 2 == 0:
        return power(n * n % mod, r // 2, mod) % mod
    if r % 2 == 1:
        return n * power(n, r - 1, mod) % mod


def comb(n, k, mod):
    a = frac[n]
    b = frac[k]
    c = frac[n - k]
    return (a * power(b, mod - 2, mod) * power(c, mod - 2, mod)) % mod


ans = 0
for i in range(N - K + 1):
    ans += (A[N - 1 - i] - A[i]) * comb(N - 1 - i, K - 1, p)
    ans = ans % p
print(ans)

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A = sorted(A)
p = 1000000007
frac = [1]
for i in range(N):
    frac.append(frac[i] * (i + 1) % p)


def comb(n, k, mod):
    a = frac[n]
    b = frac[k]
    c = frac[n - k]
    return (a * pow(b, mod - 2, mod) * pow(c, mod - 2, mod)) % mod


ans = 0
for i in range(N - K + 1):
    ans += (A[N - 1 - i] - A[i]) * comb(N - 1 - i, K - 1, p)
    ans = ans % p
print(ans)

-def power(n, r, mod): -    if r == 0: -        return 1 -    if r % 2 == 0: -        return power(n * n % mod, r // 2, mod) % mod -    if r % 2 == 1: -        return n * power(n, r - 1, mod) % mod - - -    return (a * power(b, mod - 2, mod) * power(c, mod - 2, mod)) % mod +    return (a * pow(b, mod - 2, mod) * pow(c, mod - 2, mod)) % mod