import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector.Unboxed as V
import Data.List (sort)
import qualified Data.Array as A

main :: IO ()
main = do
  (n : k : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  as <- V.fromList . sort . map unsafeSignedDecimal . T.words <$> T.getLine :: IO (V.Vector Int)
  let
    fs = do
      i <- [0..(n - k)]
      j <- [(i + (pred k))..(pred n)]
      [(c (j - succ i) (k - 2) * ((as V.! j) - (as V.! i))) `mod` modulus]
    step acc x = acc `seq` x `seq` ((acc + x) `mod` modulus)
  print . foldl step 0 $ fs

modulus :: Int
modulus = 10 ^ 9 + 7

finv :: Int -> Int
finv 0 = 1
-- finv n = (finvs V.! (pred n) * inv n) `mod` modulus
finv n = (finv (pred n) * inv n) `mod` modulus

finvs :: V.Vector Int
finvs = V.generate (10 ^ 5 + 1) finv

c :: Int -> Int -> Int
c n k | n < 0 || k < 0 || n < k = 0
      |otherwise                = (((fact n * finv k) `mod` modulus) * finv (n - k)) `mod` modulus

inv :: Int -> Int
inv 1 = 1
-- inv n = (-(invs V.! r) * q) `mod` modulus
inv n = (-(inv r) * q) `mod` modulus
  where
    (q, r) = modulus `divMod` n

invs :: V.Vector Int
invs = V.generate (10 ^ 5 + 1) inv

fact :: Int -> Int
fact 0 = 1
-- fact n = (n * (facts V.! (pred n))) `mod` modulus
fact n = (n * fact (pred n)) `mod` modulus

facts :: V.Vector Int
facts = V.generate (10 ^ 5 + 1) fact

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n
