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

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,k] <- getIntList
    as <- getIntList
    let ms = filter (<0) as
    let ps = reverse $ filter (>0) as
    let z = filter (==0) as
    let ans | k == n = solve0 as
            | length ms == n && odd k = solve2 k as
            | otherwise = solve1 (sort ms) (sortOn Down ps) z k
    print ans

solve0 as = prod as

solve1 ms ps z k = ((prod (map fst as)) * (prod bs)) `mod` 1000000007
    where ms' = map (\i -> (i,True)) $ f ms
          ps' = map (\i -> (i,False)) $ f ps
          xs = sortOn Down $ ms' ++ ps'
          as = take (k `div` 2) xs
          la = length as
          lm = length $ filter snd as
          lp = la - lm 
          rem = k - (la * 2) 
          rm = drop (lm * 2) ms
          rp = drop (lp * 2) ps
          bs = take rem . sortOn Down $ z ++ rm ++ rp 

solve2 k as = prod . take k $ sortOn Down as

f [] = []
f (x:[]) = []
f (x:y:xs) = ((x*y) `mod` 1000000007)  : f xs

prod xs = foldl' (\a b -> (a*b) `mod` 1000000007) 1 xs