/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
int N,K;
cin>>N>>K;
vector<ll> A,B;
rep(i,N){
  ll a;
  cin>>a;
  if(a>0){
    A.push_back(a);
  }
  else{
    B.push_back(a);
  }
}

int pa=0,pb=0;
mint ans=1;
int na=A.size(),nb=B.size();

  sort(all(A));
sort(all(B));
reverse(all(A));
if(K%2==0){
  rep(i,K){
    if((pa<=na-2)&&(pb<=nb-2)){
      if(A[pa]*A[pa+1]<B[pb]*B[pb+1]){
        ans*=B[pb];
        
        ans*=B[pb+1];
        
        pb+=2;
        i++;
      }
      else{
        ans*=A[pa];
        
        ans*=A[pa+1];
        
        pa+=2;
        i++;
      }
    }
    else if(pa<=na-2){
      ans*=A[pa];
      
      ans*=A[pa+1];
      
      pa+=2;
      i++;
    }
    else if(pb<=nb-2){
      ans*=B[pb];
      
      ans*=B[pb+1];

      
      pb+=2;
      i++;
    }
    else if(pa==na-1){
      ans*=A[pa];
      
      pa++;
      
    }
    else{
      ans*=B[pb];
      pb++;
      
      
    }
  }
}
else{
  if(na==0){
    reverse(all(B));
    rep(i,K){
      ans*=B[i];
      
    }
  }
  else{
    ans*=A[0];
    
    pa++;
    rep(i,K-1){
    if((pa<=na-2)&&(pb<=nb-2)){
      if(A[pa]*A[pa+1]<B[pb]*B[pb+1]){
        ans*=B[pb];
        
        ans*=B[pb+1];
        
        pb+=2;
        i++;
      }
      else{
        ans*=A[pa];
        
        ans*=A[pa+1];
        
        pa+=2;
        i++;
      }
    }
    else if(pa<=na-2){
      ans*=A[pa];
      
      ans*=A[pa+1];
      
      pa+=2;
      i++;
    }
    else if(pb<=nb-2){
      ans*=B[pb];
      
      ans*=B[pb+1];

      
      pb+=2;
      i++;
    }
    else if(pa==na-1){
      ans*=A[pa];
      
      pa++;
      
    }
    else{
      ans*=B[pb];
      pb++;
      
      
    }
  }
  }
}
  cout<<ans<<endl;
  



return 0;
}

Measured memory_bytes: 5608