#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

//for(i=0; i<N; i++) cin >> a[i];
struct mll {
  ll val;
  mll(ll val=0):val((val%MOD+MOD)%MOD){}
  
  mll pow(ll t) const {
    if (!t) return 1;
    mll a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mll inv() const { return pow(MOD-2); }
  
  mll operator-() const { return mll(-val);}
  mll& operator+=(const mll a) {
    if ((val += a.val) >= MOD) val -= MOD;
    return *this;
  }
  mll& operator-=(const mll a) {
    if ((val += MOD-a.val) >= MOD) val -= MOD;
    return *this;
  }
  mll& operator*=(const mll a) {
    (val *= a.val%MOD + MOD) %= MOD;
    return *this;
  }
  mll& operator/=(const mll a) {
    return (*this) *= a.inv();
  }
  
  mll operator+(const mll a) const {
    mll res(*this);
    return res+=a;
  }
  mll operator-(const mll a) const {
    mll res(*this);
    return res-=a;
  }
  mll operator*(const mll a) const {
    mll res(*this);
    return res*=a;
  }
  mll operator/(const mll a) const {
    mll res(*this);
    return res/=a;
  }
  
  mll& operator++(   ) { val++; return *this; }
  mll  operator++(int) { mll res(*this); val++; return res; }
  mll& operator--(   ) { val--; return *this; }
  mll  operator--(int) { mll res(*this); val--; return res; }
  
  bool operator< (const mll a) const { return val< a.val; }
  bool operator<=(const mll a) const { return val<=a.val; }
  bool operator> (const mll a) const { return val> a.val; }
  bool operator>=(const mll a) const { return val>=a.val; }
  bool operator==(const mll a) const { return val==a.val; }
  
  friend istream& operator>>(istream &input, mll &a) {
    input >> a.val;
    return input;
  }
  
  friend ostream& operator<<(ostream &output, mll &a) {
    output << a.val;
    return output;;
  }
  
};

int main(void) {
  ll i, j, k;
  
  
  ll N, K;
  cin >> N >> K;
  vector<ll> a(N);
  
  for(i=0; i<N; i++) cin >> a[i];
  //絶対値の降順ソート
  sort(a.rbegin(), a.rend(), [](const ll &a, const ll &b) { return abs(a)<abs(b); });
  
  mll ans=1;
  ll lst_pos=-INF, lst_neg=-INF; // K個中の絶対値最小
  ll nc=0;
  for(i=0; i<K; i++) {
    ans*=a[i];
    if(a[i]>0) {
      lst_pos=a[i];
    }else if(a[i]<0) {
      lst_neg=a[i];
      nc++;
    }
  }
  
  if(nc%2==0 || ans==0) { // 積>0 || 積==0
    pt(ans);
    return 0;
  }
  
  
  
  // 以下，要素を入れ替えて積>0にしたい
  ll fst_pos=-INF, fst_neg=-INF; // K個から漏れた中の絶対数最大
  for(i=N-1; i>=K; i--) {
    if(lst_neg!=-INF && a[i]>0) fst_pos=a[i];
    if(lst_pos!=-INF && a[i]<0) fst_neg=a[i];
  }
  
  if(fst_pos==-INF) {
    if(fst_neg==-INF) { //要素の入れ替え無意味 -> 積<=0が確定 -> 絶対値をなるべく小さくする方向に切り替え
      ans=1;
      for(i=N-K; i<N; i++) ans*=a[i];
    }else {
      ans=ans/lst_pos*fst_neg;
    }
  }else {
    if(fst_neg==-INF) {
      ans=ans/lst_neg*fst_pos;
    }else {
      if(fst_pos*lst_pos>fst_neg*lst_neg) ans=ans/lst_neg*fst_pos;
      else ans=ans/lst_pos*fst_neg;
    }
  }
  
  pt(ans);
  
  
}
 
 




Measured memory_bytes: 4812