#include <bits/stdc++.h>

#define       pb                 push_back
#define       sf                 scanf
#define       pf                 printf
#define       sz                 200005
#define       MOD                1000000007
#define       optimize           ios::sync_with_stdio(0);cin.tie(0);
#define       inf                0x3f3f3f3f
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);

using namespace std;

typedef       long long int      ll;
typedef       vector<int> 	     vi;

int dx[] = {0, 0, +1, -1};
int dy[] = {+1,-1, 0,  0};
/*============GRAPH MOVES==================*/
//const int fx[] = {1, -1, 0, 0};
//const int fy[] = {0, 0, 1, -1};
//const int fx[] = {0, 0, 1, -1, -1, 1, -1, 1};  // Kings move
//const int fy[] = {-1, 1, 0, 0, 1, 1, -1, -1};  // Kings move
//const int fx[] = {-2, -2, -1, -1, 1, 1, 2, 2}; // Knights move
//const int fy[] = {-1, 1, -2, 2, -2, 2, -1, 1}; // Knights move
/*=========================================*/

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool isLeapYear(ll year) { return (year%400==0) || (year%4==0 && year%100!=0); }
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }
inline ll mod(ll a, ll m){ if(a<0) return m-(abs(a)%m); else if(a<m) return a; else return (a%m); }
inline string tstring(ll a) {stringstream ss; ss << a; string str = ss.str(); return str; }

struct X
{
	ll num;
	char sign;
}a[sz];

bool comp(X A, X B)
{
	return A.num > B.num;
}

int main()
{
	// READ
	optimize

	int n, k, cn = 0, flag = 0, an = 1;

	vector <pair <int, char> > ans;

	cin >> n >> k;

	for(int i = 0; i < n; i++)
	{
		cin >> a[i].num;

		if(a[i].num>=0) a[i].sign = '+';
		else
		{
			a[i].num *= -1;
			a[i].sign = '-';
		}
	}

	sort(a, a+n, comp);

	for(int i = 0; i < k; i++)
	{
		// cout << a[i].sign << endl;

		ans.pb({a[i].num, a[i].sign});

		if(a[i].sign == '-') cn++;
		if(a[i].sign == '+') flag = 1;
	}

	if(cn%2)
	{
		if(n>k)
		{
			if(flag)
			{
				int idp = -1, idn = -1, idp1 = -1, idn1 = -1;

				for(int i = k-1; i >= 0; i--)
				{
					if(a[i].sign=='+' and idp==-1) idp = i;
					if(a[i].sign=='-' and idn==-1) idn = i;
				}

				for(int i = k; i < n; i++)
				{
					if(a[i].sign=='+' and idp1==-1) idp1 = i;
					if(a[i].sign=='-' and idn1==-1) idn1 = i;
				}

				if(idp1!=-1 and idn1!=-1)
				{
					if(a[idn].num*a[idn1].num <= a[idp].num*a[idp1].num)
					{
						ans[idn].first = a[idp1].num;
						ans[idn].second = a[idp1].sign;
					}
					else
					{
						ans[idp].first = a[idn1].num;
						ans[idp].second = a[idn1].sign;
					}
				}
				else if(idp1==-1)
				{
					ans[idp].first = a[idn1].num;
					ans[idp].second = a[idn1].sign;
				}
				else
				{
					ans[idn].first = a[idp1].num;
					ans[idn].second = a[idp1].sign;
				}
			}
			else
			{
				for(int i = k; i < n; i++)
				{
					if(a[i].sign=='+')
					{
						ans[k-1].first = a[i].num;
						ans[k-1].second = a[i].sign;
						flag = 1;
						break;
					}
				}

				if(!flag)
				{
					ans.clear();
 
					for(int i = n-1, j = 0; j < k; i--, j++)
					{
						ans.pb({a[i].num, a[i].sign});
					}
				}
			}
		}
	}

	for(int i = 0; i < k; i++)
	{
		// cout << ans[i].first << endl;

		if(ans[i].second=='-') ans[i].first *= -1;
		an = modMul(an, ans[i].first);
	}

	cout << an << endl;

    return 0;
}


Measured memory_bytes: 8444