#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

struct mint {
	ll x;
	mint(ll x=0):x((x%MOD+MOD)%MOD){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {if ((x+=a.x)>=MOD) x-=MOD; return *this;}
	mint& operator-=(const mint a) {if ((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
	mint& operator*=(const mint a) {(x*=a.x)%=MOD; return *this;}
	mint operator+(const mint a) const {mint res(*this); return res+=a;}
	mint operator-(const mint a) const {mint res(*this); return res-=a;}
	mint operator*(const mint a) const {mint res(*this); return res*=a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
 		return a;
	}

	// For prime mod.
	// Do not use if MOD is not prime number !!
	mint inv() const { return pow(MOD-2);}
	mint& operator/=(const mint a) { return (*this) *= a.inv();}
	mint operator/(const mint a) const {mint res(*this); return res/=a;}
};

ll plus_ans(vll& p, vll& m, ll k) {
    if((ll)p.size() + (ll)m.size() < k) return 0;
    mint ret = 1;
    if((ll)p.size() > 0) {
        sort(p.begin(), p.end(), greater<ll>());
    }
    vll m2;
    for(auto i : m) m2.push_back(-i);
    if((ll)m2.size() > 0) {
        sort(m2.begin(), m2.end(), greater<ll>());
    }
    ll pi = 0, mi = 0;
    while(pi + mi < k) {
//        cout << pi << ':' << mi << endl;
        if(pi < (ll)p.size() - 1 && mi < (ll)m2.size() - 1 && pi + mi < k - 1) {
//            cout << (m2.size() - 1) << endl;
//            cout << "a" << endl;
            if(p[pi] * p[pi+1] >= m2[mi] * m2[mi+1]) {
                ret *= p[pi++];
            }
            else {
                ret *= m2[mi];
                ret *= m2[mi+1];
                mi += 2;
            }
        }
        else if(mi >= (ll)m2.size() - 1 || (ll)m2.size() == 0) {
//            cout << "b" << endl;
            ret *= p[pi++];
        }
        else if(k - pi - mi >= 2 && mi < (ll)m.size() - 1) { // pは残り1つ
//            cout << "c" << endl;
            ret *= m2[mi];
            ret *= m2[mi+1];
            mi += 2;
        }
        else {
            ret *= p[pi++];
        }
    }
    return ret.x;
}

ll minus_ans(vll& p, vll& m, ll k) {
    if(p.size() > 0) {
        sort(p.begin(), p.end());
    }
    sort(m.begin(), m.end(), greater<ll>());
    mint ret = 1;
    for(ll i = 0; i < min(k, (ll)m.size()); i++) {
        ret *= m[i];
    }
    for(ll i = 0; i < k - (ll)m.size() && (ll)p.size() > 0; i++) {
        ret *= p[i];
    }
//    cout << ret.x << endl;
    return ret.x;
}

bool checkp(ll p, ll m, ll k) {
    ll a = min((k/2)*2, (m/2)*2);
    return p + a >= k;
}

void solve() {
    ll n, k;
    cin >> n >> k;
    vll a(n);
    rep(i, n) cin >> a[i];
    vll pl, mi;
    for(ll i = 0; i < n; i++) {
        if(a[i] > 0) pl.push_back(a[i]);
        else if(a[i] < 0) mi.push_back(a[i]);
    }
    ll ans = 0;
    if(checkp((ll)pl.size(), (ll)mi.size(), k)) {
//        cout << "plus" << endl;
        ans = plus_ans(pl, mi, k);
    }
    else if((ll)pl.size() + (ll)mi.size() < k) ans = 0;
    else if((ll)pl.size() + (ll)mi.size() == n) {
//        cout << "minus" << endl;
        ans = minus_ans(pl, mi, k);
    }
    else ans = 0;
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 9484