#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

bool pos(int k, int te, int ne) {
	if (te+ne<k) {return false;}
	if (te+ne==k && ne%2==1) {return false;}
	if (te==0 && k%2==1) {return false;}
	return true;
	}
	
	
ll laip(ll a, ll b, ll liek) {
	a=a%liek;
	if (b==0) {return 1;}
	if (b==1) {return a;}
	ll x=laip(a*a,b/2,liek);
	if (b%2==0) {return x;}
	return (a*x)%liek;
	}

 ll solve(vector <ll> &T,vector <ll> &N, int k, ll liek) {
	 ll ats=1;
	 ll z=1;
	 ll n=0;
	 ll t=0;
	 int i=0;
	 while (i<k) {
		 int r=T.size();
		 int e=N.size();
		 if (T.empty() || N.empty()) {
			 if (T.empty()) {ll y=N[e-1];n=y;ats=(ats*n)%liek; i++;N.pop_back();z=-z;}
			 else {ll x=T[r-1]; t=x;ats=(ats*t)%liek;i++;T.pop_back();}
			 }
		 else {
		 ll x=T[r-1];
		 ll y=N[e-1];
		 //cout<<x<<" "<<y<<endl;
		 if (x>=y) {t=x;ats=(ats*t)%liek;i++;T.pop_back();}
		 else {n=y;ats=(ats*n)%liek; i++;N.pop_back();z=-z;}}
		 }
	int r=T.size();
	int e=N.size();
	if (z==1) {return ats%liek;}
	if (T.empty() || n==0) {
		ats=(ats*laip(t,liek-2,liek))%liek;
		ats=(ats*N[e-1])%liek;
		return ats;
		}
	if (N.empty() || t==0) {
		ats=(ats*laip(n,liek-2,liek))%liek;
		ats=(ats*T[r-1])%liek;
		return ats;
		}
	if (t*T[r-1]>n*N[e-1]) {
		ats=(ats*laip(n,liek-2,liek))%liek;
		ats=(ats*T[r-1])%liek;
		return ats;
		}
		ats=(ats*laip(t,liek-2,liek))%liek;
		ats=(ats*N[e-1])%liek;
		return ats;
	}
	 
ll solve2(vector <pll> &A, int k, ll liek) {
	ll ats=1;
	for (int i=0;i<k;i++) {
		ats=(ats*A[i].first)%liek;}
	return (-ats+liek)%liek;
	}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    vector <pll> A;
    vector <ll> T;
    vector <ll> N;
    int te=0;
    int ne=0;
    int nu=0;
    for (int i=0;i<n;i++) {
		ll a;
		cin>>a;
		if (a==0) {nu++;}
		if (a>0) {te++; A.push_back({a,1});T.push_back(a);}
		if (a<0) {ne++;A.push_back({-a,-1});N.push_back(-a);}
		}
	//cout<<nu<<" "<<te<<" "<<ne<<endl;
	ll liek=1000000007;
	sort(A.begin(),A.end());
	sort(T.begin(),T.end());
	sort(N.begin(),N.end());
	if (pos(k,te,ne)) {
		cout<<solve(T,N,k,liek)<<endl;
		}
	else {
		if (nu>0) {cout<<0<<endl;}
		else {
			//cout<<"CIA"<<endl;
			cout<<solve2(A,k,liek)<<endl;
			}
		}
    return 0;
}


Measured memory_bytes: 10104