from scipy.misc import comb


def main():
    n, k = list(map(int, input().split()))
    a = sorted(list(map(int, input().split())))

    if k!= 0 and n/k>0.5:
        k = n - k

    conv_list = [comb(n-i-1, k-i, exact=True) for i in range(k+1)]

    max_sum = 0
    min_sum = 0
    print(a)
    print(conv_list)
    for i in range(k+1):
        max_sum += a[n-i-1] * conv_list[i]
        min_sum += a[i] * conv_list[i]
    ret = (max_sum - min_sum) %1000000007
    print(ret)



if __name__ == '__main__':
    main()
