#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
#define mod 1000000007
//#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT{
    __INIT(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout<<fixed<<setprecision(15);
    }
}__init;

ll mdp[200001],pdp[200001];

int main(){
    ll n,k;
    cin>>n>>k;
    vl a(n);
    vl pa;
    vl ma;
    vl za;
    rep(i,n){
        cin>>a[i];
        if(a[i] > 0) pa.push_back(a[i]);
        else if(a[i] < 0) ma.push_back(-a[i]);
        else za.push_back(a[i]);
    }
    sort(all(pa));
    sort(all(ma));
    ll pnow = (ll)pa.size()-1;
    ll mnow = (ll)ma.size()-1;
    if(k-(ll)pa.size()-(ll)ma.size() > 0){
        cout<<0<<endl;
        return 0;
    }
    bool ism = false;
    rep(i,k){
        if(pnow >=0 && mnow>=0){
            if(pa[pnow] >= ma[mnow]) pnow--;
            else{
                mnow--;
                ism = !ism;
            }
        }
        else if(pnow >= 0){
            pnow--;
        }
        else{
            mnow--;
            ism = !ism;
        }
    }
    if(ism){
        ll tmp = -inf;
        //どっちもできるとき
        if((pnow < (ll)pa.size()-1 && mnow >= 0) && (pnow >= 0 && mnow < (ll)ma.size()-1)){
            if(pa[pnow]*pa[pnow+1]<=ma[mnow]*ma[mnow+1]){
                pnow++;
                mnow--;
            }
            else{
                pnow--;
                mnow++;
            }
        }
        //p-,m+のみできるとき
        else if(pnow < (ll)pa.size()-1 && mnow >= 0){
            pnow++;
            mnow--;
        }
        else if(pnow >= 0 && mnow < (ll)ma.size()-1){
            pnow--;
            mnow++;
        }
        else{
            if(za.size() > 0){
                cout<<0<<endl;
                return 0;
            }
            pnow = 0;
            mnow = 0;
            ll ansngo = 1;
            rep(i,k){
                if(pnow < pa.size() && mnow < ma.size()){
                    if(pa[pnow] <= ma[mnow]){
                        ansngo = (ansngo*pa[pnow++])%mod;
                    }
                    else{
                        ansngo = (ansngo*ma[mnow++])%mod;
                    }
                }
                else if(pnow < pa.size()) ansngo = (ansngo*pa[pnow++])%mod;
                else ansngo = (ansngo*ma[mnow++])%mod;
            }
            if(ansngo != 0) ansngo = mod-ansngo;
            cout<<ansngo<<endl;
            return 0;
        }
    }
    ll ans = 1;
    ll tp = (ll)pa.size()-1;
    while(tp > pnow){
        ans = (ans*pa[tp--])%mod;
    }
    ll tm = (ll)ma.size()-1;
    while(tm > mnow){
        ans = (ans*ma[tm--])%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6892