#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}

vector<ll> pw2(51,1);vector<ll> pw10(19,1);
int main(){
    ll N,K; cin>>N>>K;
    ll tmp=1;
    vector<ll> A(N);
    vector<ll> minus;
    vector<ll> plus;
    vector<P> absA;
    rep(i,N){
        cin>>A[i];
        if(A[i]<0) minus.pb(A[i]);
        else if(A[i]>0) plus.pb(A[i]);
        
        absA.pb(P(abs(A[i]),A[i]));
    }
    sort(all(absA),greater<P>());
    
    if(K==N){
        ll aaa=1;
        ll aaam=0,aaap=0;
        rep(i,K){
            aaa*=absA[i].a;
            aaa%=MOD;
            if(absA[i].b<0) aaam++;
            else if(absA[i].b>0) aaap++;
        }
        
        if(aaam%2==1){
            cout<<MOD-aaa<<endl;
        }
        else{
            cout<<aaa<<endl;
        }
        return 0;
    }
    
    ll minus_size=sz(minus);
    ll plus_size=sz(plus);
    ll zero_size=N-minus_size-plus_size;
    
    ll m=0;
    ll p=0;
    
    rep(i,K){
        tmp*=absA[i].a;
        tmp%=MOD;
        if(absA[i].b<0) m++;
        else if(absA[i].b>0) p++;
    }
    //ここで0なら終わり
    if(tmp==0){
        cout<<0<<endl;
        return 0;
    }
    
    if(plus_size==0){
        if(K%2==0){
            //何もしない
        }
        else{
            if(zero_size!=0){
                cout<<0<<endl;
                return 0;
            }
            else{
                //計算
                sort(all(minus),greater<ll>());
                
                ll tmp_1 = 1;
                rep(i,K){
                    tmp_1*=(-minus[i]);
                    tmp_1%=MOD;
                }
                cout<<MOD-tmp_1<<endl;
                return 0;
            }
        }
    }
    
    // plusあり or only(-,0)&K偶 (強制zeroなし)
    // if m奇:(m,p)->(m-1,p+1)or(m+1,p-1)
    // (左)<(右) <-> (0-index) p/m-1 < m/p-1
    
    //OK
    if(m%2==0){
        cout<<tmp<<endl;
        return 0;
    }
    else{
        sort(all(minus));
        sort(all(plus),greater<ll>());
        
        ll ans=0;
        
        //以下ができない時はtmp(<0)を使う
        bool change=false;
        if((0 <= m-1)&&(m-1 <= minus_size)&&(0 <= p+1)&&(p+1 <= plus_size)){
            ll tmp_2=1;
            rep(i,m-1){
                tmp_2*=(-minus[i]);
                tmp_2%=MOD;
            }
            rep(i,p+1){
                tmp_2*=(plus[i]);
                tmp_2%=MOD;
            }
            ans=tmp_2;
            change=true;
        }
        if((0 <= m+1)&&(m+1 <= minus_size)&&(0 <= p-1)&&(p-1 <= plus_size)){
            ll tmp_3=1;
            if(!change){
                rep(i,m+1){
                    tmp_3*=(-minus[i]);
                    tmp_3%=MOD;
                }
                rep(i,p-1){
                    tmp_3*=plus[i];
                    tmp_3%=MOD;
                }
                ans=tmp_3;
            }
            else if((plus[p]*plus[p-1])<(minus[m-1]*minus[m])){
                rep(i,m+1){
                    tmp_3*=(-minus[i]);
                    tmp_3%=MOD;
                }
                rep(i,p-1){
                    tmp_3*=plus[i];
                    tmp_3%=MOD;
                }
                ans=tmp_3;
            }
            change=true;
        }
        
        if(!change){
            if(zero_size>0) cout<<0<<endl;
            else cout<<MOD-tmp<<endl;
        }
        else{
            cout<<ans<<endl;
            return 0;
        }
    }
}



Measured memory_bytes: 11024