#include "bits/stdc++.h"
using namespace std;

// Inserted snippets: euclid, io, modint, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
ll euclid(ll a, ll b, ll &x, ll &y) {
	if (b) { ll d = euclid(b, a % b, y, x);
		return y -= a/b * x, d; }
	return x = 1, y = 0, a;
}
template<ll MOD = 1'000'000'007>
struct Mod {
	ll val;
	Mod() : val(0) {}
	Mod(ll xx) {
		if (0 <= xx && xx < MOD) val = xx;
		else val = (xx % MOD + MOD) % MOD;
	}
	Mod operator+=(Mod b) { if ((val += b.val) >= MOD) val -= MOD; return *this; }
	Mod operator-=(Mod b) { if ((val += MOD - b.val) >= MOD) val -= MOD; return *this; }
	Mod operator*=(Mod b) { (val *= b.val) %= MOD; return *this; }
	Mod operator/=(Mod b) { (val *= b.inv().val) %= MOD; return *this; }
	Mod operator+(Mod b) const { Mod<MOD> tmp(*this); return tmp += b; }
	Mod operator-(Mod b) const { Mod<MOD> tmp(*this); return tmp -= b; }
	Mod operator*(Mod b) const { Mod<MOD> tmp(*this); return tmp *= b; }
	Mod operator/(Mod b) const { Mod<MOD> tmp(*this); return tmp /= b; }
	Mod& operator++() { *this += 1; return *this; }
	Mod& operator--() { *this -= 1; return *this; }
	Mod operator++(int) { Mod<MOD> tmp(*this); operator++(); return tmp; }
	Mod operator--(int) { Mod<MOD> tmp(*this); operator--(); return tmp; }
	Mod inv() const {
		ll v, y, g = euclid(val, MOD, v, y);
		assert(g == 1); return Mod((v + MOD) % MOD);
	}
	Mod operator^(ll p) const {
		ll r = 1, b = val;
		for (; p; p >>= 1, b = b * b % MOD) if (p & 1) r = r * b % MOD;
		return Mod(r);
	}
	friend istream& operator>>(istream &is, Mod& mod) {
		ll tmp; is >> tmp;
		mod = Mod<MOD>(tmp);
		return is;
	}
	friend ostream& operator<<(ostream &os, const Mod& mod) {
		return os << mod.val;
	}
};
// End snippets

typedef Mod<> modint;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n, k; read(n, k);
	vector<ll> pos, neg, zero;
	rep(i, 0, n) {
		ll t; read(t);
		if (t == 0) zero.push_back(t);
		else if (t > 0) pos.push_back(t);
		else neg.push_back(t);
	}
	sort(pos.rbegin(), pos.rend());
	sort(neg.begin(), neg.end());
	if (pos.size() + neg.size() < k)
		die(0);
	modint prod = 1;

	if (k == pos.size() + neg.size()) {
		if (neg.size() % 2 == 1 && zero.size() > 0)
			die(0);
		for (ll x : pos) prod *= x;
		for (ll y : neg) prod *= y;
	} else if (pos.size() == 0) {
		// check positive or negative
		if (k % 2 == 1) {
			reverse(all(neg));
			if (zero.size() > 0) die(0);
		}
		rep(i, 0, k) prod *= neg[i];
	} else {
		// always possible to maximize positive
		int poseat = min((int)pos.size(), k);
		if (poseat % 2 != k % 2)
			poseat--;
		int negeat = k - poseat;
		while (poseat >= 2 && negeat + 2 <= neg.size() &&
				neg[negeat] * neg[negeat + 1] > pos[poseat - 1] * pos[poseat - 2])
			negeat += 2, poseat -= 2;
		rep(i, 0, poseat) prod *= pos[i];
		rep(i, 0, negeat) prod *= neg[i];
	}

	write(prod);
}


Measured memory_bytes: 5580