#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<stdlib.h>
//#include<string.h>
//#include<algorithm>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)

#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pLL pair<long long,long long>
#define pDB pair<double,double>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
//#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
#define popcountL __builtin_popcountll
#define popcount __builtin_popcount
/// int other=mask^((1<<n)-1);
typedef long long ll;
typedef long long int lln;
typedef pair<int,int> pii;
ll INF=1<<28;
//typedef long long lld;
const double PI=acos(-1.0);
//int fx[]={1,-1,0,0}; //direction array
//int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
int knight[8][2]={1,2,1,-2,2,1,2,-1,-1,2,-1,-2,-2,1,-2,-1};
const long double EPS=1e-7;
//#define INF 10000

struct compare
{
  bool operator()(const pair<int,pii>& l, const pair<int,pii>& r)
  {
      if(l.ff==r.ff)
      {
          return l.sn.ff>r.sn.ff;
      }
      return l.ff<r.ff;
  }
};
// bool operator<(pair<int,pii> l, pair<int,pii> r)
//  {
//      if(l.ff==r.ff)
//      {
//          cout<<"ok "<<endl;
//          return l.sn.ff<r.sn.ff;
//      }
//      return l.ff>r.ff;
//  }

/////////////////////////////////////template sesh/////////////////////////////////////////////////////

///code goes from here
const int mx=500150;
///
int mod=1000000007;

vector<ll>pos,neg,arr;
double cumpos[mx],cumneg[mx];
bool cmpV(ll a,ll b)
{
    return abs(a)<abs(b);
}
int main()
{
//    SPEED;
    int n,k;
    sf2(n,k);
    ll x;
    int flag=0;
    for(int i=0;i<n;i++)
    {
        sl(x);
        if(x<0)
        {
            neg.pb(x*-1);
        }
        else if(x>0)
        {
            pos.pb(x);
        }
        else
            flag=1;
        arr.pb(abs(x));
    }
    sort(pos.begin(),pos.end());
    reverse(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());
    reverse(neg.begin(),neg.end());
    int y=pos.size()+neg.size();
    if(y<k)
    {
        cout<<0<<endl;
        return 0;
    }
    double sum=0;
    for(int i=0;i<pos.size();i++)
    {
        double y=log10(pos[i]);
        sum+=y;
        cumpos[i]=sum;

    }
    sum=0;
    for(int i=0;i<neg.size();i++)
    {
        double y=log10(neg[i]);
        sum+=y;
        cumneg[i]=sum;
    }
    int ans=-1;
    int ps=pos.size();
    int ng=neg.size();
//    cout<<ps<<" and "<<ng<<endl;
    double maxx=0;
    for(int i=0;i<=min(k,ps);i++)
    {
        int nibo=k-i;
//        cout<<nibo<<endl;
        if(nibo%2)
            continue;
        if(nibo>ng)
            continue;
        sum=0;
        if(i>0)
        sum=cumpos[i-1];
        if(nibo>0)
        sum+=cumneg[nibo-1];
//        cout<<sum<<endl;
        if(sum>=maxx)
        {
            maxx=sum;
            ans=i;
        }
    }
    ll ansmul=1;
    if(ans==-1)
    {
//        cout<<"ok"<<endl;
        sort(arr.begin(),arr.end());
        for(int i=0;i<k;i++)
        {
            ansmul*=arr[i];
            ansmul%=mod;
        }
        ansmul*=-1;
        cout<<(ansmul+mod)%mod<<endl;
        return 0;
    }
    int nibo=k-ans;
    for(int i=0;i<ans;i++)
    {
        ansmul*=pos[i];
        ansmul%=mod;
    }
    for(int i=0;i<nibo;i++)
    {
        ansmul*=neg[i];
        ansmul%=mod;
    }
    cout<<ansmul<<endl;

    return 0;
}



Measured memory_bytes: 9372