import Data.List
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

headc [] = 1
headc (s:ss) = s

solve :: [Integer] -> [Integer] -> Int -> Integer
solve [] [] 0 = 1
solve (p:ps) (m:ms) 0 = 1
solve (p:ps) [] 0 = 1
solve [] (m:ms) 0 = 1
solve [] [] i = 1
solve (p:ps) [] i = p * solve ps [] (i-1)
solve [] (m:ms) i = m * solve [] ms (i-1)
solve (p:ps) (m:ms) i | p >= mm = p * solve ps (m:ms) (i-1)
                      | i >= 2 = mm * solve (p:ps) (tail ms) (i-2)
                      | otherwise = 1
                        where
                            mm = m * (headc ms)

main = do
    [n,k] <- readInts
    as <- sort <$> readIntegers
    let pas = reverse $ filter (>=0) (drop ((length as) - k) as)
    let mas = filter (<0) (take k as)
    let msas = reverse $ filter (<0) (as)
    let scs = solve pas mas k
    let mis = solve pas msas k
    if scs >= 0
        then print $ scs `mod` (1000000007)
        else print $ mis `mod` (1000000007)