#include <bits/stdc++.h>

#define int long long
#define double long double

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll=long long;
using ld=double;

constexpr int MOD = 1e9+7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

template<int64_t MOD>
class ModInt {
	typedef int64_t T;
	T x;

  public:
	ModInt(T value) {
		if (value < 0) value = (MOD - (-value) % MOD);
		x = value % MOD;
	}

	ModInt operator-() const {
		return ModInt(-x);
	}

	ModInt& operator+=(const ModInt& p) {
		if ((x += p.get()) >= MOD) x -= MOD;
		return *this;
	}

	ModInt& operator-=(const ModInt& p) {
		if ((x += MOD - p.get()) >= MOD) x -= MOD;
		return *this;
	}

	ModInt& operator*=(const ModInt& p) {
		x = x * p.get() % MOD;
		return *this;
	}

	ModInt& operator/=(const ModInt& p) {
		*this *= p.inverse();
		return *this;
	}

	ModInt& operator+=(const T& p) {
		return *this += ModInt(p);
	}

	ModInt& operator-=(const T& p) {
		return *this -= ModInt(p);
	}

	ModInt& operator*=(const T& p) {
		return *this *= ModInt(p);
	}

	ModInt& operator/=(const T& p) {
		return *this /= ModInt(p);
	}

	ModInt operator+(const ModInt& p) const {
		return ModInt(*this) += p;
	}

	ModInt operator-(const ModInt& p) const {
		return ModInt(*this) -= p;
	}

	ModInt operator*(const ModInt& p) const {
		return ModInt(*this) *= p;
	}

	ModInt operator/(const ModInt& p) const {
		return ModInt(*this) /= p;
	}

	ModInt operator+(const T& p) const {
		return ModInt(*this) += p;
	}

	ModInt operator-(const T& p) const {
		return ModInt(*this) -= p;
	}

	ModInt operator*(const T& p) const {
		return ModInt(*this) *= p;
	}

	ModInt operator/(const T& p) const {
		return ModInt(*this) /= p;
	}

	bool operator==(const ModInt& p) const {
		return x == p.get();
	}

	bool operator!=(const ModInt& p) const {
		return x != p.get();
	}

	bool operator==(const T& p) const {
		return x == ModInt(p);
	}

	bool operator!=(const T& p) {
		return x != ModInt(p);
	}

	ModInt inverse() const {
		int a = x, b = MOD, u = 1, v = 0;
		while (b) {
			int t = a / b;
			a -= t * b;
			u -= t * v;
			swap(a, b);
			swap(u, v);
		}
		return ModInt(u);
	}

	T get() const {
		return x;
	}

	friend ostream& operator<<(ostream& out,const ModInt& value){
	    out<<value.x;
	    return out;
	}
};

using moi=ModInt<MOD>;

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    int p=0,z=0,cn=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]>0)p++;
        else if(a[i]==0)z++;
        else cn++;
    }
    sort(a.begin(),a.end());

    moi ans(1);
    if(n==k){
        rep(i,n){
            ans*=a[i];
        }
    }
    else{
        if(cn+p<k)ans=0;
        else if(cn+p==k&&cn%2){
            ans=0;
        }
        else if(p==0&&k%2){
            if(z>0)ans=0;
            else{
                rep(i,k){
                    ans*=a[n-i-1];
                }
            }
        }
        else{
            vector<int> memo(0);
            if(k%2){
                ans=a[n-1];
                rep(i,(p-1)/2){
                    memo.push_back(a[n-i*2-2]*a[n-i*2-3]);
                }
            }
            else{
                rep(i,(p)/2){
                    memo.push_back(a[n-i*2-1]*a[n-i*2-2]);
                }
            }
            rep(i,cn/2){
                memo.push_back(a[i*2]*a[i*2+1]);
            }
            sort(memo.begin(),memo.end(),greater<>());
            rep(i,k/2)ans*=memo[i];
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 5836