#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;
ll mod_inv(ll base , ll up , ll mod)
{
	ll val = 1;
	while(up)
	{
		if(up%2)
			val = (val * base)%mod;
		base = (base * base)%mod;	
		up/=2;
	}	
	
	return val;
}
int main()
{
	int n,k;cin>>n>>k;
	
	vector<pair<ll ,ll >  > vec;
	
	for(int i = 0;i<n;i++)
	{
		ll x;
		cin>>x;
		vec.push_back(mp(abs(x) , x));
	}
	
	sort(vec.begin() , vec.end());
	
	int neg = 0;
	ll val = 1;
	int lastpos  = -1, lastneg = -1;
	for(int i = n-1;i>=n-k;i--)
	{
		if(vec[i].second < 0)
		{
			lastneg = i;
			neg++;
		}
		else lastpos = i;
		
		val = (val * (vec[i].second + MOD)%MOD)%MOD;
	}
	
	if(neg%2 == 0)
	{
		cout<<val<<endl;
		return 0;
	}
	
	int lastpost = -1 , lastnegt = -1;
	
	for(int i = n-k-1;i>=0;i--)
	{
		if(vec[i].second < 0 && lastnegt == -1) lastnegt = i;
		
		if(vec[i].second >= 0 && lastpost == -1) lastpost = i;	
	}
	
	
	if((lastnegt == -1 || lastpos == -1) && (lastpost == -1 || lastneg == -1))
	{
		ll val = 1;
		
		for(int i = 0;i<k;i++)
		{
			val = (val * (vec[i].second + MOD)%MOD)%MOD;	
		}
		
		cout<<val<<endl;
		
	}
	else if((lastnegt == -1 || lastpos == -1))
	{
		val = (val * vec[lastpost].second)%MOD;
		ll d = (vec[lastneg].second + MOD)%MOD;
		val = (val * mod_inv(d , MOD - 2 , MOD))%MOD;
		cout<<val<<endl;
			
	}
	else if((lastpost == -1 || lastneg == -1))
	{
		val = (val * mod_inv(vec[lastpos].second , MOD-2 , MOD))%MOD;
		val = (val * (vec[lastnegt].second + MOD)%MOD)%MOD;
		cout<<val<<endl;
	}
	else
	{
		if(vec[lastpos].second*vec[lastpost].second >= vec[lastneg].second*vec[lastnegt].second)
		{
			val = (val * vec[lastpost].second)%MOD;
			ll d = (vec[lastneg].second + MOD)%MOD;
			val = (val * mod_inv(d , MOD - 2 , MOD))%MOD;
			cout<<val<<endl;
		}
		else
		{
			val = (val * mod_inv(vec[lastpos].second , MOD-2 , MOD))%MOD;
			val = (val * (vec[lastnegt].second + MOD)%MOD)%MOD;
			cout<<val<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 7456