#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 long long    
#define vi                 vector<ll >
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define int                long long                        
#define pb                 push_back                                                     
#define mii                map<ll ,ll >
#define rep(i, a, b)       for(ll  i=a;i<b;i++)
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define hell               1000000007
// #define hell               (ll)998244353
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define mp                 make_pair
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define inf                3223372036854775807
#define endl               '\n' 
#define PI                  3.14159265
#define N                  (int) 1e6 + 5
ll n, m, k, a[N];


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    ll tests = 1;
    // cin >> tests;
    rep(test, 1, tests+1)
    {
        cin >> n >> k;
        priority_queue<int> all, neg, pos, zer;
        rep(i, 0, n)
        {
        	cin >> a[i];
        	if(a[i] == 0)
        	{
        		all.push(a[i]);
        		zer.push(a[i]);
        		continue;
        	}
        	if(a[i] > 0)
        	{
        		pos.push(a[i]);
        		all.push(-a[i]);
        		continue;
        	}
        	neg.push(-a[i]);
        	all.push(a[i]);
        }
        int szpos = sz(pos), szneg = sz(neg) - sz(neg) % 2, szzer = sz(zer);
        int key = 0;
        if(k % 2 == 0)
        {
        	if(szpos + szneg < k)
        	{
        		if(szzer > 0)
        		{
        			cout << 0 << endl;
        			return 0;
        		}
        		key = 1;
        	}
        }
        else
        {
        	if(szpos + szneg < k)
        	{
        		if(szzer > 0)
        		{
        			cout << 0 << endl;
        			return 0;
        		}
        		key = 1;
        	}
        	else if(szpos == 0)
        	{
        		if(szzer > 0)
        		{
        			cout << 0 << endl;
        			return 0;
        		}
        		key = 1;
        	}
        }
    	int ans = 1;
        if(key)
        {
        	while(k--)
        	{
        		ans *= -all.top();
        		all.pop();
        		ans %= hell;
        	}
        	cout << hell - ans << endl;
        	return 0;
        }
        stack<int> chospos;
        stack<int> prevans;
        while(k > 1)
        {
        	int mexpos = 1, mexneg = 1;
        	int key2 = 0, key3 = 0;
        	if(sz(pos) > 1)
        	{
        		key2 = 1;
        		mexpos = pos.top();
        		pos.pop();
        	}
        	if(sz(neg) > 1)
        	{
        		key3 = 1;
        		mexneg = neg.top();
        		neg.pop();
        	}
        	if(sz(neg) == 0)
        	{
        		chospos.push(mexpos);
        		prevans.push(ans);
        		ans *= mexpos;
        		ans %= hell;
        		ans *= pos.top();
        		chospos.push(pos.top());
        		pos.pop();
        		ans %= hell;
        		k -= 2;
        		continue;
        	}
        	if(!key2 or mexneg * neg.top() >= mexpos * pos.top())
        	{
        		if(key2)
        		pos.push(mexpos);
        		ans *= mexneg;
        		ans %= hell;
        		ans *= neg.top();
        		neg.pop();
        		ans %= hell;
        	}
        	else
        	{
        		chospos.push(mexpos);
        		if(key3)
        		neg.push(mexneg);
        		prevans.push(ans);
        		ans *= mexpos;
        		ans %= hell;
        		ans *= pos.top();
        		chospos.push(pos.top());
        		pos.pop();
        		ans %= hell;
        	}
        	k -= 2;
        }
    	if(k == 1)
    	{
    		if(sz(pos))
    		{
    			ans *= pos.top();
    			pos.pop();
    			ans %= hell;
    		}
    		else
    		{
    			ans = prevans.top();
    			ans *= neg.top();
    			neg.pop();
    			ans %= hell;
    			ans *= neg.top();
    			neg.pop();
    			ans %= hell;
    			chospos.pop();
    			ans *= chospos.top();
    			chospos.pop();
    			ans %= hell;
    		}
    	}
    	cout << ans << endl;
    }

    #ifdef LOCAL
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}

Measured memory_bytes: 10176