void main() {
  problem();
}

void problem() {
  const N = scan!int;
  const K = scan!int;
  const A = scan!long(N).sort().sort!((a, b) => a.abs > b.abs).array;

  long solve() {

    {
      const minusCount = A.count!(a => a < 0);
      const zeroCount = A.count!(a => a == 0);
      const plusCount = N - zeroCount - minusCount;

      if (K % 2 == 1 && plusCount == 0) {
        if (zeroCount > 0) return 0;

        long ans = 1;
        foreach(i; N-K..N) {
          ans = ans.mulmod(A[i]);
        }
        return ans;
      }
    }

    long ans = 1;
    bool isMinus;
    int lastMinus;

    long beforeMinus = 1;
    long afterMinus = 1;

    foreach(i; 0..K) {
      if (A[i] == 0) return 0;

      if (A[i] > 0) {
        afterMinus = afterMinus.mulmod(A[i]);
      }
      
      if (A[i] < 0 && !isMinus) {
        beforeMinus = ans;
      }

      if (A[i] < 0) {
        isMinus ^= true;
        afterMinus = 1;
      }

      ans = ans.mulmod(A[i]);
    }

    if (isMinus && K < N) {
      ans = beforeMinus.mulmod(afterMinus);

      bool updated;
      foreach(i; K..N) {
        if (A[i] <= 0) continue;

        ans = ans.mulmod(A[i]);
        updated = true;
        break;
      }

      if (!updated) {
        ans = ans.mulmod(A[$-1]);
      }
    }

    return ans;
  }

  solve().writeln;
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

enum MOD = 10^^9 + 7;
long mulmod(long a, long b) { auto m = a * b; return m < 0 ? MOD + (m % MOD) : m % MOD; }

// -----------------------------------------------
