#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int dpx[8]={1,1,1,-1,-1,-1,0,0};
int dpy[8]={-1,1,0,1,-1,0,-1,1};

int bin_exp(int b,int e)
{
	if(e==0)	
		return 1;
	int a=bin_exp(b,e/2);
	if(e&1)	
		return a*a*b;
	else 
		return a*a;
}

int powm(int x,int y,int m=MOD) 
{
	x=x%m;
	int res=1;
	while(y)
	{
		if(y&1)
			res=res*x;
		res%=m;
		y=y>>1;
		x=x*x;
		x%=m;
	}
	return res;
}

int modInverse(int a,int m=MOD)
{
	return powm(a,m-2,m);
}



int32_t main()
{
	fastIO
	inp_out();
	int n, k; 
	cin >> n >> k;
	vi a(n); 

	vector < pii > v;
	int zero_present = 0;  
	for(int i = 0; i < n;  ++ i)
	{
		cin >> a[i];
		int x = abs(a[i]); 
		if(a[i] != 0)
			v.pb({x, a[i] / x});  
		else zero_present = 1; 
	}

	sort(v.begin(), v.end(), greater < pii > ()); 

	if(v.size()  < k)
	{
		cout << 0; 
		return 0; 
	}

	int pc = 0, nc = 0; 
	int ans  = 1, ln, lp =  - 1; 

	for(int i = 0; i < k;  ++ i)
	{
		ans *= v[i].fi; 
		ans %= MOD; 

		if(v[i].se ==  - 1)
		{
			ln = v[i].fi; 
			nc ++ ; 
		}
		else
		{
			lp = v[i].fi; 
			pc ++ ;
		} 

	}

	if(nc % 2 == 0)
	{
		cout << ans;
		return 0;  
	}

	else
	{
		int pos =  - 1, neg =  - 1; 
		for(int i = k; i < v.size();  ++ i)
		{
			if(v[i].se == 1 && pos ==  - 1)
			{
				pos = v[i].fi; 
			}
			if(v[i].se == -1  &&  neg == - 1)
			{
				neg = v[i].fi; 
			}
		}

		if(pos !=  - 1  &&  neg !=  - 1 && lp !=  -1)
		{
			if(pos * lp > neg * ln)
			{
				ans *= pos; 
				ans  %= MOD; 
				ans *= modInverse(ln); 
				ans  %= MOD; 
			}
			else
			{
				ans *= neg; 
				ans %= MOD; 
				ans *= modInverse(lp); 
				ans %= MOD; 
			}
			cout << ans; 
			return 0; 
		}

		if(pos !=  - 1)
		{
			ans *= pos; 
			ans  %= MOD; 
			ans *= modInverse(ln); 
			ans  %= MOD; 
			cout << ans; 
			return 0; 
		}

		if(neg !=  -1 && lp !=  - 1)
		{
			ans *= neg; 
			ans %= MOD; 
			ans *= modInverse(lp); 
			ans %= MOD;
			cout << ans; 
			return 0; 
		}


		if(zero_present)
		{
			cout << 0; 
			return 0; 
		}

		else
		{
			reverse(v.begin(), v.end()); 
			ans = 1; 
			for(int i = 0; i < k;  ++ i)
			{
				ans *= v[i].fi; 
				ans  %= MOD; 
			}
			ans =  -ans; 
			ans   =  (ans % MOD  +  MOD) % MOD; 
			cout << ans; 
		}
	}


	return 0;
}
  


Measured memory_bytes: 8972