/*input

*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  100005
lld expo(lld base,lld exponent,lld mod){
    lld ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
void solve()
{
	vi pos,neg;
	lld n,k;
	cin >> n >> k;
	vi alx;
	rep(i,0,n){
		lld x;
		cin >> x;
		alx.pb(abs(x));
		if(x>=0){
			pos.pb(x);
		}
		else{
			neg.pb(-x);
		}
	}
	sort(all(alx));
	lld ans2=1;
	rep(i,0,k){
		ans2=(ans2*alx[i])%hell;
	}
	sort(all(pos));
	sort(all(neg));
	reverse(all(pos));
	reverse(all(neg));
	lld i=0,j=0,negc=0,tot=0;
	lld ans=1;
	while(i<pos.size() && j<neg.size() && tot<k){
		if(pos[i]>=neg[j]){
			ans=(ans*pos[i])%hell;
			i++;
		}
		else{
			ans=(ans*neg[j])%hell;
			j++;
			negc++;
		}
		tot++;
	}
	while(i<pos.size() && tot<k){
		ans=(ans*pos[i])%hell;
		i++,tot++;
	}
	while(j<neg.size() && tot<k){
		ans=(ans*neg[j])%hell;
		j++,tot++,negc++;
	}
	if(negc%2){
		if(j==neg.size() && i<pos.size()){
			ans=(ans*expo(neg[j-1],hell-2,hell))%hell;
			ans=(ans*pos[i])%hell;
			cout << ans << endl;
		}
		else if(j==neg.size() && i==pos.size()){
			cout << (hell-ans)%hell << endl;
		}
		else{
			if(i==0){
				if(pos.size()==0){
					cout << (hell-ans2)%hell << endl;
				}
				else{
					ans=(ans*pos[i])%hell;
					ans=(ans*expo(neg[j-1],hell-2,hell))%hell;
					cout << ans << endl;
				}
			}
			else{
				if(i!=pos.size()){
					lld p1=pos[i-1]*pos[i];
					lld p2=neg[j-1]*neg[j];
					if(p1>p2){
						ans=(ans*expo(neg[j-1],hell-2,hell))%hell;
						ans=(ans*pos[i])%hell;
					}
					else{
						ans=(ans*expo(pos[i-1],hell-2,hell))%hell;
						ans=(ans*neg[j])%hell;
					}
					cout << ans << endl;
				}
				else{
					ans=(ans*expo(pos[i-1],hell-2,hell))%hell;
					ans=(ans*neg[j])%hell;
					cout << ans << endl;	
				}
			}
		}
	}
	else{
		cout << ans << endl;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 7548