let () =
    let mul_inv a = function
        | 1 -> 1
        | b ->
            let rec aux a b x0 x1 =
                if a <= 1 then x1 else
                if b = 0 then failwith "mul_inv" else
                    aux b (a mod b) (x1 - (a / b) * x0) x0
            in
            let x = aux a b 0 1 in
            if x < 0 then x + b else x
    in
    let m = 1_000_000_000 + 7 in
    let ( +@ ) a b = (a + b) mod m in
    let ( -@ ) a b = (a - b + m) mod m in
    let ( *@ ) a b = ((a mod m) * (b mod m)) mod m in
    let ( /@) a b = a *@ mul_inv b m in
    let main () =
        let n, k = Scanf.scanf "%d %d" (fun n k -> n, k) in
        let arr = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
        Array.sort compare arr;
        let rec loop fact a b i acc =
            if i = n then acc else
                let acc = acc +@ fact *@ (arr.(i) -@ arr.(n - 1 - i)) in
                loop (fact *@ a /@ b) (a + 1) (b + 1) (i + 1) acc
        in
        loop 1 k 1 (k - 1) 0 |> Printf.printf "%d\n"
    in
    main ()