{-# LANGUAGE TypeApplications #-}

-- | E - Multiplication 4
module Main where

import Control.Monad (filterM)
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 . words <$> getLine
  print $ (product as) `mod` 1000000007
  where
    powerset :: [a] -> [[a]]
    powerset xs = filterM (\x -> [True, False]) xs
