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

#define sz(a) ((int)a.size())
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define forse(i,s,e) for(int i=(int)s;i<(int)e;i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using dbl=double;
using ll=long long;
using pii=pair<int, int>;
using pll=pair<ll, ll>;

dbl PI=3.141592653589793;

//Modular arithmetic
template<int P>
class Modular{
	public:
		static int init_siz;
		static vector<Modular> inverse,factorial;
		int n=0;
		static Modular exp(Modular a, long long e) {
			Modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
			return res;
		}
		static void init(int n){
			init_siz=n;
			inverse.resize(n+1);factorial.resize(n+1);
			factorial[0] = 1;
			for (int i = 1; i <= n; i++) factorial[i] = factorial[i - 1] * i;
			inverse[n]=exp(factorial[n],P-2);
			for (int i = n-1; i>=0; i--) inverse[i] = inverse[i+1] * (i+1);
		}
		static Modular inv(Modular const& a){
			assert(a.n!=0);
			return (init_siz>=a.n? inverse[a.n]*fac(a-1):exp(a,P-2));
		}
		static Modular cinv(Modular const& a){
			return (init_siz>=a.n? inverse[a.n]:exp(fac(a),P-2));
		}
		static Modular fac(Modular const& a){
			if(init_siz>=a.n) return factorial[a.n];
			else{
				Modular out=1;
				for(int i=0;i<a.n;i++) out*=(i+1);
				return out;
			}
		}
		Modular(long long val = 0) {n=val%P;if(n<0) n+=P;}
		Modular& operator+=(Modular const& b) {n += b.n; if (n >= P) n -= P; return *this;}
		Modular& operator-=(Modular const& b) {n -= b.n; if (n < 0) n += P;return *this;}
		Modular& operator*=(Modular const& b) {n = (long long)n * b.n % P;return *this;}
		Modular exp(long long e) {return exp(*this,e);}
		Modular inv(){return inv(*this);}
		Modular& operator/=(Modular const& b){ return *this *=inv(b);}	
		friend std::ostream& operator<<(std::ostream& os,Modular const& a){return os<<a.n;}
		friend Modular operator+(Modular a, Modular const b) { return a += b; }
		friend Modular operator-(Modular a, Modular const b) { return a -= b; }
		friend Modular operator-(Modular const a) { return 0 - a; }
		friend Modular operator*(Modular a, Modular const b) { return a *= b; }
		friend Modular operator/(Modular a, Modular const b) { return a /= b; }
		friend bool operator==(Modular const& a, Modular const& b) {return a.n == b.n;}
		friend bool operator!=(Modular const& a, Modular const& b) {return a.n != b.n;}
};
template<int P> int Modular<P>::init_siz=-1;
template<int P> vector<Modular<P>> Modular<P>::factorial;
template<int P> vector<Modular<P>> Modular<P>::inverse;
template<int P> string to_string(Modular<P> b) { return to_string(b.n);}
const int P=1e9+7;
typedef Modular<P> mint;


void solve(){
	int n,k;
	cin >> n >> k;

	vector<pll> in;
	int ncnt=0,zcnt=0;
	forn(i,n){
		int inp;cin >> inp;
		if(inp) in.pb({abs(inp),inp});
		else zcnt++;
	}
	
	sort(all(in));
	reverse(all(in));

	n=sz(in);
	if(k>n){
		cout << 0;
		return;
	}

	forn(i,k){
		if(in[i].se<0) ncnt++;
	}

	mint out=1;
	if(ncnt&1){
		int bng=k,bpos=k,nng=k-1,npos=k-1;
		forn(i,k){
			if(in[i].se<0) bng=i;
			else bpos=i;
		}
		for(int i=n-1;i>=k;i--){
			if(in[i].se<0) nng=i;
			else npos=i;
		}

		if(bng<k&&bpos<k&&nng>=k&&npos>=k){
			if(in[npos].fi*in[bpos].fi>in[bng].fi*in[nng].fi){
				forn(i,k){
					if(i!=bng) out*=in[i].se;
				}
				out*=in[npos].se;
			}else{
				forn(i,k){
					if(i!=bpos) out*=in[i].se;
				}
				out*=in[nng].se;
			}
		}else if(bng<k&&npos>=k){
			forn(i,k){
				if(i!=bng) out*=in[i].se;
			}
			out*=in[npos].se;
		}else if(bpos<k&&nng>=k){
			forn(i,k){
				if(i!=bpos) out*=in[i].se;
			}
			out*=in[nng].se;
		}else{
			if(zcnt){
				cout << 0;
				return;
			}
			reverse(all(in));
			forn(i,k) out*=in[i].se;
		}
	}else{
		forn(i,k) out*=in[i].se;
	}
	cout << out;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int T=1;
//	cin >> T;
	for(int c=1;c<=T;c++){
		solve();
	}
}


Measured memory_bytes: 7420