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

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

modulus :: Int
modulus = 10 ^ 9 + 7

finv :: Int -> Int
finv = (finvs V.!)
  where
    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 = (invs V.!)
  where
    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 = (facts V.!)
  where
    fact' 0 = 1
    fact' n = (n * (facts V.! (pred n))) `mod` modulus
    -- fact' n = (n * fact (pred n)) `mod` modulus
    -- fact' n = (n * facts A.! (pred n)) `mod` modulus
    facts :: V.Vector Int
    facts = V.generate (10 ^ 5 + 1) fact'
    -- facts :: A.Array Int Int
    -- facts = A.listArray (0, 10 ^ 5) . map fact $ [0..(10 ^ 5)]

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