import Data.List
import Data.Char
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as BS8
import qualified Data.Vector as Vector
import Data.Vector ((!))

import GHC.Exts

main :: IO ()
main = do
  [n, k] <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine
  a <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine
  let
    sa = reverse $ sortWith abs a
    pa = foldr (*) 1 $ take (k-1) sa

  print $ (`mod` (10^9 + 7)) $ maximum $ map (pa *) $ drop (k-1) sa
