#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

#define ll long long
const int maxN = 100005;
const int MOD = 1000000007;

class TaskE {
private:
	Debugger debugger;
	ll mul(ll a, ll b){
		a %= MOD;
	    a = (a + MOD) % MOD;
		b %= MOD;
		b = (b + MOD) % MOD;
		return a * b % MOD;
	}

	ll getPositive(vector<ll> &positives, vector<ll> &negatives, int k){
			sort(positives.rbegin(), positives.rend());
			sort(negatives.rbegin(), negatives.rend());
			ll ans = 1;
			int pp = 0, nn = 0;
			while(k > 0){
				if(pp == positives.size()){
					ans = mul(ans, negatives[nn]);
					ans = mul(ans, negatives[nn+1]);
					nn += 2;
					k -= 2;
					continue;
				}
				if(nn == negatives.size()){
					ans = mul(ans, positives[pp]);
					pp++;
					k--;
					continue;
				}

				if(nn+1 < negatives.size() and k >= 2){
					if( pp+1 >= positives.size() or negatives[nn] * negatives[nn+1] > positives[pp] * positives[pp+1] ){
						ans = mul(ans, negatives[nn]);
						ans = mul(ans, negatives[nn+1]);
						nn += 2;
						k-=2;
					}else{
						ans = mul(ans, positives[pp]);
						pp++;
						k--;
					}
				}else{
					ans = mul(ans, positives[pp]);
					pp++;
					k--;
				}
			}
			return ans;
	}
	ll getNegative(vector<ll> &positives, vector<ll> &negatives, int k){
			sort(positives.begin(), positives.end());
			sort(negatives.begin(), negatives.end());
			ll ans = 1;
			int pp = 0, nn = 0;
			while(k > 0){
				if(pp == positives.size()){
					ans = mul(ans, negatives[nn]);
					nn++;
					k--;
					continue;
				}
				if(nn == negatives.size()){
					ans = mul(ans, positives[pp]);
					pp++;
					k--;
					continue;
				}
				if(positives[pp] < negatives[nn]){
					ans = mul(ans, positives[pp]);
					pp++;
					k--;
				}else{
					ans = mul(ans, negatives[nn]);
					nn++;
					k--;
				}
			}
			ans = mul(ans, -1);
			return ans;
	}

public:
	void solveOne(int it){
		int n, k;
		cin >> n >> k;
		int zeros = 0;
		vector<ll> positives, negatives;
		for(int i = 0; i < n; i++){
			ll x;
			cin >> x;
			if(x == 0){
				zeros++;
			}else if(x > 0){
				positives.push_back(x);
			}else{
				negatives.push_back(-x);
			}
		}
		if(n - zeros < k){
			cout << 0 << endl;
			return;
		}
		bool ok = false;
		for(int neg = 0; neg <= negatives.size() and neg <= k; neg += 2){
			if(neg + positives.size() >= k){
				ok = true;
			}
		}

		if(ok){
			cout << getPositive(positives, negatives, k) << endl;
		}else{
			if(zeros > 0){
				cout << 0 << endl;
			}else{
				cout << getNegative(positives, negatives, k) << endl;	
			}
		}

	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskE solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 5512