#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

// MOD p でいくつクラス
#define MOD 1000000007 // 10^9 + 7
class mll {
	unsigned long long val = 0;
public:
	mll(long long y = 0) : val(((y % MOD) + MOD) % MOD) {}
	mll operator + (const mll& y) { return mll(*this) += y; }
	mll& operator += (const mll& y) {
		val = (val + y.val) % MOD;
		return *this;
	}
	mll operator - (const mll& y) { return mll(*this) -= y; }
	mll& operator -= (const mll& y) {
		val = (val - y.val + MOD) % MOD;
		return *this;
	}
	mll operator * (const mll& y) { return mll(*this) *= y; }
	mll& operator *= (const mll& y) {
		val = (val * y.val) % MOD;
		return *this;
	}
	mll operator / (const mll& y) { return mll(*this) /= y; }
	mll& operator /= (const mll& y) {
		long long a = y.val, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		mll c = val * u; // この計算でoverflowしないか？
		val = c.val;
		return *this;
	}
	bool operator >= (const mll& y) {
		return this->val >= y.val;
	}
	mll pow(long long t) const {
		if (!t) return 1;
		mll a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	unsigned long long getVal() {
		return val;
	}
	friend ostream& operator <<(ostream& os, mll& y) {
		os << y.val;
		return os;
	}
};
#undef MOD

int main() {
	int N, K;
	cin >> N >> K;

	multiset<ll> Sn;
	multiset<ll> Sp;
	mll allProd = 1;
	int zeros = 0;
	for (int i = 0; i < N; i++) {
		ll a;
		cin >> a;
		allProd *= a;
		if (a < 0) {
			Sn.insert(-a);
		}
		else if (a > 0) {
			Sp.insert(a);
		}
		else {
			zeros++;
		}
	}

	if (N == K) {
		cout << allProd.getVal() << endl;
		return(0);
	}
	if (Sn.size() + Sp.size() < K) {
		cout << 0 << endl;
		return(0);
	}
	mll p = 1;
	if (Sp.size() == 0) {
		if (K % 2 == 1) {
			auto it = Sn.begin();
			for (int i = 0; i < K; i++) {
				if (it == Sn.end()) {
					cout << 0 << endl;
					return(0);
				}
				p *= *it;
				it++;
			}
			p *= -1;
			if (zeros > 0) {
				cout << 0 << endl;
			}
			else {
				cout << p.getVal() << endl;
			}
			return(0);
		}
		else { // K:even
			auto it = Sn.rbegin();
			for (int i = 0; i < K; i++) {
				if (it == Sn.rend()) {
					cout << 0 << endl;
					return(0);
				}
				p *= *it;
				it++;
			}
			cout << p.getVal() << endl;
			return(0);
		}
	}
	// 以下、K < N and Sp.size() > 0 
	if (K % 2 == 1) {
		p *= *Sp.rbegin();
		Sp.erase((++Sp.rbegin()).base());
		K--;
	}
	// 以下、Kはeven
	while (K > 0) {
		if (Sp.size() >= 2) {
			ll pp = (*Sp.rbegin()) * (*(++Sp.rbegin()));
			if (Sn.size() >= 2) {
				ll nn = (*Sn.rbegin()) * (*(++Sn.rbegin()));
				if (pp <= nn) {
					p *= nn;
					K -= 2;
					Sn.erase((++Sn.rbegin()).base());
					Sn.erase((++Sn.rbegin()).base());
				}
				else {
					p *= pp;
					K -= 2;
					Sp.erase((++Sp.rbegin()).base());
					Sp.erase((++Sp.rbegin()).base());
				}
			}
			else {
				p *= pp;
				K -= 2;
				Sp.erase((++Sp.rbegin()).base());
				Sp.erase((++Sp.rbegin()).base());
			}
		}
		else if(Sn.size() >= 2){
			ll nn = (*Sn.rbegin()) * (*(++Sn.rbegin()));
			p *= nn;
			K -= 2;
			Sn.erase((++Sn.rbegin()).base());
			Sn.erase((++Sn.rbegin()).base());
		}
		else {
			p *= *Sn.rbegin();
			p *= *Sp.rbegin();
			K -= 2;
			Sn.erase((++Sn.rbegin()).base());
			Sp.erase((++Sp.rbegin()).base());
		}
	}

	cout << p.getVal() << endl;
	return(0);
}


Measured memory_bytes: 12996