-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeOperators #-}
import Data.Char (isSpace)
import Data.Int (Int64)
import Data.List (unfoldr)
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.Vector.Algorithms.Merge as A
import qualified Data.ByteString.Char8 as BS
import GHC.TypeNats (Nat, KnownNat, natVal, type (^), type (+))

solve :: U.Vector Int64 -> U.Vector Int64 -> Int -> N
solve n p k = loop (U.toList n) (U.toList p) k 1
  where
    loop :: [Int64] -> [Int64] -> Int -> N -> N
    loop _ _ 0 acc = acc
    loop [] ps !l !acc = acc * product (map fromIntegral $ take l ps)
    loop ns [] !l !acc = let m = length ns
                         in if odd l then
                              error "unexpected"
                            else
                              acc * product (map fromIntegral $ take l ns)
    loop ns@(n0:n1:ns') ps@(p0:ps'@(p1:_)) !l !acc
      | n0 * n1 >= p0 * p1 = loop ns' ps (l - 2) (acc * fromIntegral (n0 * n1))
      | otherwise = loop ns ps' (l - 1) (acc * fromIntegral p0)
    loop [n0] ps !l !acc = let m = length ps
                           in if m < l then
                                error "unexpected"
                              else
                                acc * product (map fromIntegral $ take l ps)
    loop ns [p0] !l !acc
      | odd l = acc * product (map fromIntegral $ take (l - 1) ns) * fromIntegral p0
      | otherwise = let m = length ns
                    in if m >= l then
                         acc * product (map fromIntegral $ take l ns)
                       else
                         error "unexpected"

main = do
  [n,k] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  as <- U.map fromIntegral . U.modify A.sort . U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let n, nn, z, p :: U.Vector Int64
      (n, nn) = U.span (< 0) as
      (z, p) = U.span (== 0) nn
  let result :: N
      result = case compare (U.length n + U.length p) k of
                 LT -> 0
                 EQ | not (U.null z) && odd (U.length n) -> 0
                    | otherwise -> product (map fromIntegral $ U.toList n) * product (map fromIntegral $ U.toList p)
                 GT | U.null p -> if U.null z || even k then
                                    product (map fromIntegral $ U.toList $ U.drop (U.length n - k) n)
                                  else
                                    0
                    | otherwise -> solve n (U.reverse p) k
  print result

--
-- Modular Arithmetic
--

type N = IntMod (10^9 + 7)

newtype IntMod (m :: Nat) = IntMod { unwrapN :: Int64 } deriving (Eq)

instance Show (IntMod m) where
  show (IntMod x) = show x

instance KnownNat m => Num (IntMod m) where
  t@(IntMod x) + IntMod y
    | x + y >= modulus = IntMod (x + y - modulus)
    | otherwise = IntMod (x + y)
    where modulus = fromIntegral (natVal t)
  t@(IntMod x) - IntMod y
    | x >= y = IntMod (x - y)
    | otherwise = IntMod (x - y + modulus)
    where modulus = fromIntegral (natVal t)
  t@(IntMod x) * IntMod y = IntMod ((x * y) `rem` modulus)
    where modulus = fromIntegral (natVal t)
  fromInteger n = let result = IntMod (fromInteger (n `mod` fromIntegral modulus))
                      modulus = natVal result
                  in result
  abs = undefined; signum = undefined

{-# RULES
"^9/Int" forall x. x ^ (9 :: Int) = let u = x; v = u * u * u in v * v * v
"^9/Integer" forall x. x ^ (9 :: Integer) = let u = x; v = u * u * u in v * v * v
 #-}

fromIntegral_Int64_IntMod :: KnownNat m => Int64 -> IntMod m
fromIntegral_Int64_IntMod n = result
  where
    result | 0 <= n && n < modulus = IntMod n
           | otherwise = IntMod (n `mod` modulus)
    modulus = fromIntegral (natVal result)

{-# RULES
"fromIntegral/Int->IntMod" fromIntegral = fromIntegral_Int64_IntMod . (fromIntegral :: Int -> Int64) :: Int -> IntMod (10^9 + 7)
"fromIntegral/Int64->IntMod" fromIntegral = fromIntegral_Int64_IntMod :: Int64 -> IntMod (10^9 + 7)
 #-}
