#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

const long int INF=1000000007;

int main(){
    int N,K;
    cin>>N>>K;
    vector<long int> A(N),B,C;
    bool z=false;
    rep(i,N){
        cin>>A[i];
        if (A[i]>0) B.push_back(A[i]);
        if (A[i]==0) z=true;
        if (A[i]<0) C.push_back(A[i]); 
    }
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    int p=B.size(),q=C.size();
    long long ans=1;
    if (p==0){
        if (q<K){
            cout<<0<<endl;
            return 0;
        }
        else{
            if (K%2==0){
                rep(i,K){
                    ans=ans*(-C[i]);
                    ans=ans%INF;
                }
                cout<<ans<<endl;
                return 0;
            } 
            else{
                if (z){
                    cout<<0;
                    return 0;
                }
                rep(i,K){
                    ans=ans*(-C[q-1-i]);
                    ans=ans%INF;
                }
                cout<<INF-ans<<endl;
                return 0;
            }
        }
    }
    if (N==K){
        for(int i=0;i<N;i++){
            ans=ans*abs(A[i]);
            ans=ans%INF;
        }
        if (z) cout<<0<<endl;
        else if (q%2==1) cout<<INF-ans<<endl;
        else cout<<ans<<endl;
        return 0;
    }
    int s,t;
    if (p+q<K){
        cout<<0<<endl;
        return 0;
    }
    if (p>=K){
        t=p-K;
        s=0;
        while(true){
            if (t+1<p&&s+1<q){
                long long n=B[t]*B[t+1];
                long long m=C[s]*C[s+1];
                if (n<m){
                    s+=2;
                    t+=2;
                }
                else break;
            }
            else break;
        }
        for (int i=t;i<p;i++){
            ans=ans*B[i];
            ans=ans%INF;
        }
        for (int i=0;i<s;i++){
            ans=ans*(-C[i]);
            ans=ans%INF;
        }
        cout<<ans<<endl;
        return 0;
    }
    if ((K-p)%2==0){
        t=0;
        s=K-p;
        while(true){
            if (t+1<p&&s+1<q){
                long long n=B[t]*B[t+1];
                long long m=C[s]*C[s+1];
                if (n<m){
                    s+=2;
                    t+=2;
                }
                else break;
            }
            else break;
        }
        for (int i=t;i<p;i++){
            ans=ans*B[i];
            ans=ans%INF;
        }
        for (int i=0;i<s;i++){
            ans=ans*(-C[i]);
            ans=ans%INF;
        }
        cout<<ans<<endl;
        return 0;
    }
    else{
        t=1;
        s=K-p+1;
        while(true){
            if (t+1<p&&s+1<q){
                long long n=B[t]*B[t+1];
                long long m=C[s]*C[s+1];
                if (n<m){
                    s+=2;
                    t+=2;
                }
                else break;
            }
            else break;
        }
        for (int i=t;i<p;i++){
            ans=ans*B[i];
            ans=ans%INF;
        }
        for (int i=0;i<s;i++){
            ans=ans*(-C[i]);
            ans=ans%INF;
        }
        cout<<ans<<endl;
        return 0;
    }
    
    return 0;
}

Measured memory_bytes: 6900