/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 100005;
const ll mm = 1e+18;
long long power(long long x, long long y)
{
   long long res = 1;
   x = x % mod;
   while (y > 0)
   {
       if (y & 1)
            res = (res*x) %mod;
       y = y>>1;
       x = (x*x) %mod;
   }
   return res;
}
void solve()
{
    int n,k;
    cin>>n>>k;
    vector<int>p,ne;
    int z=0;
    int xx=1;
    rep0(i,n){
        int x;
        cin>>x;
        xx=(xx*x)%mod;
        if(xx<0) xx+=mod;
        if(x>0) p.pb(x);
        else if(x<0) ne.pb(x);
        else z++;
    }
    if(k==n){
        cout<<xx;
        return;
    }
    if((int)(p.si)+(int)(ne.si)<k){
        cout<<0;
        return;
    }
    sort(p.beg,p.en);
    reverse(p.beg,p.en);
    sort(ne.beg,ne.en);
    int res=1;
    if(k<(int)(p.si)+(int)(ne.si)){
        if((k&1)&&!(p.size())){
            if(z) res=0;
            else{
                while(k--){
                    res=(res*ne.back())%mod;
                    if(res<0) res+=mod;
                    ne.pop_back();
                }
            }
        }
        else if(!(p.size())){
            if((int)(ne.size())<k) res=0;
            else{
                rep0(i,k) res=(res*ne[i])%mod;
                if(res<0) res+=mod;
            }
        }
        else{
            int x=(int)(p.si)-min(k,(int)(p.si));
            if((k-min(k,(int)(p.si)))&1) x++;
            while(x--){
                p.pop_back();
            }
            reverse(p.beg,p.en);
            for(auto x:p) res=(res*x)%mod;
            int rem=k-p.size();
            deb(rem);
            rep0(i,rem) res=(res*ne[i])%mod;
            int here=rem;
            int i=0;
            while(here+1<(int)(ne.size())&&i+1<(p.size())){
                if(ne[here]*ne[here+1]>p[i]*p[i+1]){
                    res=(res*power(p[i],mod-2))%mod;
                    res=(res*power(p[i+1],mod-2))%mod;
                    res=(res*ne[here])%mod;
                    res=(res*ne[here+1])%mod;
                    here+=2;
                    i+=2;
                }
                else break;
            }
            //deb(i,here);
        }
    }
    else if(k==(int)(p.si)+(int)(ne.si)){
        for(auto x:p) res=(res*x)%mod;
        for(auto x:ne) res=(res*x)%mod;
        if(((int)(ne.si)&1)&&z) res=0;
    }
    else res=0;
    if(res<0) res+=mod;
    cout<<res;
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 5560