#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#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)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

/* modとる */
inline ll modu(ll a){
    return(a % mod + mod) % mod;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N,K;
    cin >> N >> K;
    vector<ll> plus(0);
    vector<ll> minus(0);
    vector<ll> zeros(0);
    REP(i,N){
        ll ge;
        cin >> ge;
        if(ge == 0){
            zeros.pb(ge);
        }else if(ge > 0){
            plus.pb(ge);
        }else{
            minus.pb(ge);
        }
    }
    sort(ALL(minus));
    sort(ALL(plus),greater<>());
    ll hugou = 1;
    ll pn = 0;
    ll mn = 0;
    REP(i,K){
        if(pn < plus.size()&&mn < minus.size()){
            if(plus[pn] > minus[mn]*(-1)){
                pn++;
            }else{
                mn++;
                hugou*=-1;
            }
        }else if(pn < plus.size()){
            pn++;
        }else if(mn < minus.size()){
            mn++;
            hugou*=-1;
        }else{
            hugou = 0;
        }
    }
    if(hugou == 0){
        cout << 0 << "\n";
    }else if(hugou == 1){
        ll ans = 1;
        REP(i,pn){
            ans = modu(ans*plus[i]);
        }
        REP(i,mn){
            ans = modu(ans*minus[i]);
        }
        cout << ans << "\n";
    }else{
        ll ans = 1;
        if(plus.size() == 0){
            if(zeros.size() == 0){
                sort(ALL(minus),greater<>());
                REP(i,K)ans = modu(ans*minus[i]);
            }else{
                ans = 0;
            }
        }else{
            if(pn < plus.size()&&mn < minus.size()){
                if(pn == 0){
                    pn++;
                    mn--;
                }else{
                    if(plus[pn]*plus[pn-1] > minus[mn]*minus[mn-1]){
                        pn++;
                        mn--;
                    }else{
                        pn--;
                        mn++;
                    }
                }
            }else if(pn < plus.size()){
                pn++;
                mn--;
            }else if(mn < minus.size()){
                pn--;
                mn++;
            }else{
                if(zeros.size()!=0){
                    hugou = 0;
                }
            }
            if(hugou == 0){
                ans = 0;
            }else{
                REP(i,pn){
                    ans = modu(ans*plus[i]);
                }
                REP(i,mn){
                    ans = modu(ans*minus[i]);
                }
            }
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 5608