#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>
#include <omp.h>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;

const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
//const long long int pl=1000000;
long long int N,K,A[200020],res=0,zero=0;
priority_queue<long long int>pq;
vector<long long int>pl,mi,fin;

int main(){

    cout << fixed << setprecision(18);
    cin>>N>>K;
    for(long long int i = 0; i < N; i++){
        cin>>A[i];
        if(A[i]>0){pl.push_back(A[i]);}
        else if(A[i]<0){mi.push_back(A[i]);}
        else{zero++;}
    }
    //0が多く絶対に0を選ばないといけない場合
    if(pl.size()+mi.size()<K){cout<<0<<endl;return 0;}

    //最大値が正になる場合
    if(pl.size()>0&&pl.size()+(mi.size())/2*2>=K||pl.size()==0&&K%2==0){
        sort(pl.begin(),pl.end(),greater<long long int>());
        sort(mi.begin(),mi.end());
        
            long long int nokori=K/2;
        if(K%2==1){
            res=pl[0];
            
            for(long long int i = 1; i+1 < pl.size(); i+=2){
                
                fin.push_back(pl[i]*pl[i+1]);
            }
            for(long long int i = 0; i+1 < mi.size(); i+=2){
                
                fin.push_back(mi[i]*mi[i+1]);
            }
        }else{
            res=1;
            
            for(long long int i = 0; i+1 < pl.size(); i+=2){
                
                fin.push_back(pl[i]*pl[i+1]);
            }
            for(long long int i = 0; i+1 < mi.size(); i+=2){
                
                fin.push_back(mi[i]*mi[i+1]);
            }
        }
        sort(fin.begin(),fin.end(),greater<long long int>());
        //cout<<nokori<<" "<<res<<endl;
        for(long long int i = 0; i < nokori; i++){
            res*=(fin[i]%mod);
            res%=mod;
        }
        cout<<res<<endl;
        return 0;
    }

    if(zero!=0){
        cout<<0<<endl;
        return 0;
    }

    if(pl.size()==0){
        res=1;
        sort(mi.begin(),mi.end(),greater<long long int>());
        for(long long int i = 0; i < K; i++){
            res*=mi[i];
            res%=mod;
        }
        cout<<(res+mod)%mod;
        return 0;
    }
    res=1;
    for(long long int i = 0; i < N; i++){
        res*=A[i];
        res%=mod;
    }
    cout<<(res+mod)%mod<<endl;
    return 0;
    
}



Measured memory_bytes: 8200