#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}


template<uint32_t mod>
struct ModInt{
	uint32_t a;
	ModInt& s(uint32_t vv){
		a=vv<mod?vv:vv-mod;
		return *this;
	}

    ModInt(int64_t x=0){s(x%mod+mod);}

	ModInt& operator+=(const ModInt &x){return s(a+x.a);}
	ModInt& operator-=(const ModInt &x){return s(a+mod-x.a);}
	ModInt& operator*=(const ModInt &x){
		a=uint64_t(a)*x.a%mod;
		return *this;
	}
	ModInt& operator/=(const ModInt &x){
		*this*=x.inv();
		return *this;
	}

	ModInt operator+(const ModInt &x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt &x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt &x)const{return ModInt(*this)*=x;}
	ModInt operator/(const ModInt &x)const{return ModInt(*this)/=x;}
	bool operator==(const ModInt &x)const{return a==x.a;}
	bool operator!=(const ModInt &x)const{return a!=x.a;}
	bool operator<(const ModInt &x)const{return a<x.a;}

	ModInt operator-()const{return ModInt()-*this;}
	ModInt pow(int64_t n)const{
		ModInt res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}

    ModInt inv()const{return pow(mod-2);}
};

template<uint32_t mod>
istream& operator>>(istream& in,ModInt<mod>& a){
	return (in>>a.a);
}
template<uint32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
	return (out<<a.a);
}
using mint=ModInt<1000000007>;
//using mint=ModInt<998244353>;

int N,K;


signed main(){
	cin>>N>>K;

	vint neg,pos;
	int z=0;
	rep(i,N){
		int a;cin>>a;
		if(a>0)pos.pb(a);
		else if(a<0)neg.pb(-a);
		else z++;
	}

	sort(all(neg));
	sort(all(pos));


	//positive

	if((K%2==0||K%2==1&&pos.size())&&neg.size()/2+(pos.size()-K%2)/2>=K/2){
		mint ans=1;
		if(K&1){
			ans*=pos.back();
			pos.pop_back();
			K--;
		}
		vint lis;
		for(int i=0;i+1<pos.size();i+=2)lis.pb(pos[pos.size()-1-i]*pos[pos.size()-1-i-1]);
		for(int i=0;i+1<neg.size();i+=2)lis.pb(neg[neg.size()-1-i]*neg[neg.size()-1-i-1]);
		sort(all(lis));
		reverse(all(lis));
		for(int i=0;i<K/2;i++)ans*=lis[i];
		cout<<ans<<endl;
		return 0;
	}



	//zero
	if(z){
		cout<<0<<endl;
		return 0;
	}

	//negative
    reverse(all(pos));
	reverse(all(neg));
	mint ans=-neg.back();
	neg.pop_back();
	K--;
	if(K&1){
		ans*=pos.back();
		pos.pop_back();
		K--;
	}
	

	vint lis;
	for(int i=0;i+1<pos.size();i+=2)lis.pb(pos[pos.size()-1-i]*pos[pos.size()-1-i-1]);
	for(int i=0;i+1<neg.size();i+=2)lis.pb(neg[neg.size()-1-i]*neg[neg.size()-1-i-1]);
	sort(all(lis));
	for(int i=0;i<K/2;i++)ans*=lis[i];
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 6592