Scanf.scanf "%d %d" (fun n k ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    Array.sort (fun a b -> compare (abs a) (abs b)) a;

    let z = 1_000_000_007 in

    let ( *@) a b = (((a * b) mod z) + z) mod z in

    let rec loop rest i m z p minm minp =
        if rest = 0 then m, z, p, minm, minp else
            let m = if a.(i) < 0 then m + 1 else m in
            let z = if a.(i) = 0 then z + 1 else z in
            let p = if a.(i) > 0 then p + 1 else p in
            loop (rest - 1) (i - 1) m z p (if a.(i) < 0 then i else minm) (if a.(i) > 0 then i else minp)
    in
    let m, z, p, minm, minp = loop k (n - 1) 0 0 0 n n in
    let prod f t =
        let rec loop i acc =
            if i > t then acc else loop (i + 1) (acc *@ a.(i))
        in
        loop f 1
    in
    let prod2 f t skip alter =
        let rec loop i acc =
            if i > t then acc else
                let acc = if i = skip then acc else acc *@ a.(i) in
                loop (i + 1) acc
        in
        loop f a.(alter)
    in
    Printf.printf "%d\n" @@ if z > 0 then 0 else ( (* z = 0 *)
        if k = n then prod 0 (n - 1) else
        if m mod 2 = 0 then prod (n - k) (n - 1) else ( (* z = 0 && m % 2 = 1 *)
            let rec loop i maxm maxp zero =
                if i = n - k then maxm, maxp, zero else
                    if a.(i) > 0 then loop (i + 1) maxm i zero else
                    if a.(i) < 0 then loop (i + 1) i maxp zero else
                                      loop (i + 1) maxm maxp true
            in
            let maxm, maxp, zero = loop 0 (-1) (-1) false in
            (* case:
                * p > 0 && m % 2 = 1:
                    * maxm >= 0 && maxp >= 0 -> compare prod / a.(minm) * a.(maxp)
                                                        prod / a.(minp) * a.(maxm)
                    * maxm >= 0 && maxp <  0 -> prod / a.(minp) * a.(maxm)
                    * maxm <  0 && maxp >= 0 -> prod / a.(minm) * a.(maxp)
                    * else -> 0
                * p = 0 && m % 2 = 1 && zero -> 0
                * p = 0 && m % 2 = 1 && !zero -> phase2
             *)
            if p > 0 then (
                if maxm >= 0 && maxp >= 0 then (
                    if a.(maxp) * a.(minp) > a.(maxm) * a.(minm) then prod2 (n - k) (n - 1) minm maxp
                                                                 else prod2 (n - k) (n - 1) minp maxm
                ) else
                if maxm >= 0 && maxp <  0 then prod2 (n - k) (n - 1) minp maxm else
                if maxm <  0 && maxp >= 0 then prod2 (n - k) (n - 1) minm maxp else 0
            ) else if zero then 0 else prod 0 (k - 1)
        )
    )
)