///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

 main()

{
    fast
    int n,k,x;
    cin>>n>>k;
    vector<pi>vec;
    int z=0;
    f(i,1,n)
    {
        cin>>x;
        if(x==0)z=1;
        else if(x<0)
        {
            vec.pb(mp(-x,1));
        }
        else
        {
            vec.pb(mp(x,0));
        }
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    int sz=vec.size();
    if(sz<k)
     {
         cout<<"0"<<endl;
         return 0;
     }
    vector<int>pos,neg;
    for(int i=0;i<k;i++)
    {
         int val=vec[i].fi;
         int typ=vec[i].si;
         if(typ==1)neg.pb(val);
         else pos.pb(val);
    }
    sort(pos.rbegin(),pos.rend());
    sort(neg.rbegin(),neg.rend());
    int nsz=neg.size();
    if(nsz%2==0)
    {
         int ses=1;
         for(auto x:pos)
         {
             ses=gun(ses,x);
         }
         for(auto x:neg)ses=gun(ses,x);
         cout<<ses<<endl;
         return 0;
    }
    int big_pos=-1,big_neg=-1;
    for(int i=k;i<sz;i++)
    {
        int val=vec[i].fi;
        int typ=vec[i].si;
        if(typ==1 && big_neg==-1)
        {
            big_neg=val;
        }
        if(typ==0 && big_pos==-1)
        {
            big_pos=val;
        }
        if(big_neg!=(-1) && big_pos!=(-1))break;
    }
    int last_pos=-1,last_neg=-1;
    if(pos.size()>=1)last_pos=pos.back();
    if(neg.size()>=1)last_neg=neg.back();
     if(last_pos==-1)big_neg=-1;
     if(last_neg==-1)big_pos=-1;
    if(big_pos==-1 && big_neg==-1)
    {
        if(z==1)
        {
            cout<<"0"<<endl;
            return 0;
        }
        int ses=1;
        sort(vec.begin(),vec.end());
           for(int i=0;i<k;i++)
        {
         int val=vec[i].fi;
         int typ=vec[i].si;
          if(typ==1)val=-val;
          ses=gun(ses,val);
        }
        cout<<ses<<endl;
        return 0;

    }
    if(big_pos!=(-1) && big_neg!=(-1))
    {
        int x=big_pos*last_pos;
        int y=big_neg*last_neg;
        if(x>y)
        {
            big_neg=-1;
        }
        else
        {
            big_pos=-1;
        }
    }
    if(big_pos==-1)
    {
        pos.pop_back();
        neg.pb(big_neg);
        int ses=1;
        for(auto x:pos)ses=gun(ses,x);
        for(auto x:neg)ses=gun(ses,x);
        cout<<ses<<endl;
        return 0;
    }
    if(big_neg==-1)
    {
        neg.pop_back();
        pos.pb(big_pos);
        int ses=1;
        for(auto x:pos)ses=gun(ses,x);
        for(auto x:neg)ses=gun(ses,x);
        cout<<ses<<endl;
        return 0;
    }
    return 0;

}





































Measured memory_bytes: 10032