#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
// int const mod = 998244353;
int const mod = 1e9+7;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x , int m){
    return power(x,m-2,m);
}

int const N = 2e5+5;
int const inf = 2e9;


void solve(){  
    int i,j,l;
    int n,k;
    cin >> n >> k;
    set<pii> pos,neg;
    for(i=0;i<n;i++){
        int x; cin >> x;
        if(x >= 0) pos.insert({x,i});
        else neg.insert({-1*x,i});
    }

    int cntp = 0;
    int cntn = 0;
	pos.insert({-inf,n});
	neg.insert({-inf,n});
	set<pii> tpos,tneg;
    
    int ans = 1;
    
    while(cntp+cntn < k){
		int x = (*pos.rbegin()).first;
		int y = (*neg.rbegin()).first;
		if(x >= y){
			ans = (ans*(x%mod))%mod;
			pos.erase(pos.find(*pos.rbegin()));
			cntp++;
			tpos.insert({x,cntp});
		}
		else{
			ans = (ans*(y%mod))%mod;
			neg.erase(neg.find(*neg.rbegin()));
			cntn++;
			tneg.insert({y,cntn});
		}	
    }

	if(cntn%2 == 1){
		int p1 = -inf;
		int p2 = -inf;
		int n1 = -inf;
		int n2 = -inf;
		if(pos.size() > 1 && tneg.size() > 0){
			p1 = (*pos.rbegin()).first;
			n1 = (*tneg.begin()).first;
		}
		if(tpos.size() > 0 && neg.size() > 1){
			p2 = (*tpos.begin()).first;
			n2 = (*neg.rbegin()).first;
		}

		if(p1 != -inf && p2 != -inf){
			ld r1 = (ld)p1/(ld)n1;
			ld r2 = (ld)n2/(ld)p2;

			if(r1 >= r2){
				ans = (ans*(p1%mod))%mod;
				ans = (ans*(inverse(n1,mod)%mod))%mod;
				cntp++;
				cntn--;
			}
			else{
				ans = (ans*(n2%mod))%mod;
				ans = (ans*(inverse(p2,mod)%mod))%mod;
				cntp--;
				cntn++;
			}
		}	
		else if(p1 != -inf){	
			ans = (ans*(p1%mod))%mod;
			ans = (ans*(inverse(n1,mod)%mod))%mod;
			cntp++;
			cntn--;
		}
		else if(p2 != -inf){
			ans = (ans*(n2%mod))%mod;
			ans = (ans*(inverse(p2,mod)%mod))%mod;
			cntp--;
			cntn++;
		}
		else{
			int z = cntn;
			while(neg.size() > 1){
				int x = (*neg.rbegin()).first;
				int y = (*tneg.rbegin()).first;
				ans = (ans*(x%mod))%mod;
				ans = (ans*(inverse(y,mod)%mod))%mod;
				neg.erase(neg.find(*neg.rbegin()));
				tneg.erase(tneg.find(*tneg.rbegin()));
				z++;
				tneg.insert({x,z});
			}
		}
	}

	if(cntn%2) ans = ans*(-1);
	ans = (ans%mod + mod)%mod;
	cout<<ans<<endl;
}           


int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}


/*


*/

Measured memory_bytes: 16132