// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 1000005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 1005;
const long double epsilon = 1e-9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {

	fast
	ll n, k;
	cin >> n >> k;
	vl a(n);
	vl pos, neg, zero;
	loop(i, n)
	{
		ll el;
		cin >> el;
		a[i] = el;
		if (el == 0)
			zero.pb(el);
		else if (el > 0)
			pos.pb(el);
		else
			neg.pb(el);
	}
	ll x = ll(pos.size()), y = ll(neg.size()), z = ll(zero.size());
	if (k > x + y)
	{
		cout << 0 << END;
	}
	else
	{
		ll t = (y % 2 != 0) ? y - 1 : y;
		ll key = 1;
		if (k > x + t)
		{
			if (z > 0)
				key = 0;
			else
				key = -1;
		}
		else
		{
			if (x > 0 || k % 2 == 0)
				key = 1;
			else
			{
				if (z > 0)
					key = 0;
				else
					key = -1;
			}
		}
		if (key == 0)
			cout << 0 << END;
		else if (key == 1)
		{
			if (!pos.empty())
				sort(all(pos), greater<ll>());
			if (!neg.empty())
				sort(all(neg));
			ll i = 0, j = 0;
			ll ans = 1;
			while (k > 1)
			{
				if (x - i > 1 && y - j > 1)
				{
					if (1LL * pos[i]*pos[i + 1] > 1LL * neg[j]*neg[j + 1])
					{
						ans = (ans * pos[i] % MOD) % MOD;
						ans = (ans * pos[i + 1] % MOD) % MOD;
						i += 2;
					}
					else
					{
						ans = (ans * neg[j] % MOD) % MOD;
						ans = (ans * neg[j + 1] % MOD) % MOD;
						j += 2;
					}
				}
				else if (x - i > 1)
				{
					ans = (ans * pos[i] % MOD) % MOD;
					ans = (ans * pos[i + 1] % MOD) % MOD;
					i += 2;
				}
				else
				{
					ans = (ans * neg[j] % MOD) % MOD;
					ans = (ans * neg[j + 1] % MOD) % MOD;
					j += 2;
				}
				k -= 2;
			}
			if (k && i < x)
				ans = (ans * pos[i] % MOD) % MOD;
			cout << (ans + MOD) % MOD << END;
		}
		else
		{
			if (!pos.empty())
				sort(all(pos));
			if (!neg.empty())
				sort(all(neg), greater<ll>());
			ll i = 0, j = 0;
			ll ans = 1;
			if (k & 1)
			{
				ans = (ans * neg[j] % MOD) % MOD , ++j;
				--k;
			}
			while (k > 0 && (x - i > 1 || y - j > 1))
			{
				if (x - i > 1 && y - j > 1)
				{
					if (1LL * pos[i]*pos[i + 1] < 1LL * neg[j]*neg[j + 1])
					{
						ans = (ans * pos[i] % MOD) % MOD;
						ans = (ans * pos[i + 1] % MOD) % MOD;
						i += 2;
					}
					else
					{
						ans = (ans * neg[j] % MOD) % MOD;
						ans = (ans * neg[j + 1] % MOD) % MOD;
						j += 2;
					}
					k -= 2;
				}
				else if (x - i > 1)
				{
					ans = (ans * pos[i] % MOD) % MOD;
					ans = (ans * pos[i + 1] % MOD) % MOD;
					i += 2;
					k -= 2;
				}
				else if (y - j > 1)
				{
					ans = (ans * neg[j] % MOD) % MOD;
					ans = (ans * neg[j + 1] % MOD) % MOD;
					j += 2;
					k -= 2;
				}
			}
			if (k > 0)
			{
				if (k > 1)
				{
					ans = (ans * pos[i] % MOD) % MOD;
					ans = (ans * neg[j] % MOD) % MOD;
				}
				else
				{
					if (i < x)
					{
						ans = (ans * pos[i] % MOD) % MOD;
					}
					else
					{
						ans = (ans * neg[j] % MOD) % MOD;
					}
				}
			}
			cout << (ans + MOD) % MOD << END;
		}
	}


// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}


Measured memory_bytes: 6860