{-# LANGUAGE TypeApplications #-}

-- | E - Multiplication 4
module Main where

import qualified Data.ByteString.Char8 as BS
import Data.List (sortOn)
import Data.Ord (Down(Down))

main :: IO ()
main = do
  (n : k : _) <- map (read @Int) . words <$> getLine
  as <- take k . sortOn Down . map (read . BS.unpack) . BS.words <$> BS.getLine
  print $ (product as) `mod` 1000000007
