#include<bits/stdc++.h>
using namespace std;

#define mp make_pair
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef unsigned long long ull;

ll MOD = 1000000007;

int main(){
    int n,k;
    int countP=0,countN=0;
    vector<ll> posi,nega;
    int zero;

    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++){
        ll temp;
        scanf("%lld",&temp);
        if(temp==0){
            zero++;
        }else{
            if(temp<0){
                countN++;
                nega.push_back(temp);
            }else{
                countP++;
                posi.push_back(temp);
            }
        }
    }
    //printf("debug1\n");
    if(countN+countP<k){
        printf("0\n");
    }else{
        //printf("debug2\n");
        if(countN+countP==k&&countN%2==1||!countP&&k&1){
            if(zero){
                printf("0");
            }else{
                //printf("debug31\n");
                //harus negatif -> ambil paling kecil
                sort(all(posi));
                sort(all(nega),greater<ll>());
                //printf("sorted\n");
                for(int i=0;i<nega.size();i++){
                    nega[i]*=-1;
                }
                //printf("positived\n");
                vector<ll> unite;
                //merge(posi.begin(),posi.end(),nega.begin(),nega.end(),unite.begin());
                unite.insert(unite.end(),all(posi));
                unite.insert(unite.end(),all(nega));
                sort(all(unite));
                //printf("merged\n");
                //for(auto i = unite.begin();i!=unite.end();i++){
                //    printf("%d ",*i);
                //}
                //printf("\n");

                ll res=1;
                for(int i=0;i<k;i++){
                    //printf("%lld\n",unite[i]);
                    res= ((unite[i]%MOD) * res)%MOD;
                }
                res%=MOD;
                res = MOD-res;
                printf("%lld\n",res);
            }
        }else{
            //printf("debug32\n");
            //printf("%d %d\n",countN,countP);
            //bisa positif
            sort(posi.begin(),posi.end(),greater<ll>());
            sort(nega.begin(),nega.end());


            //printf("posi\n");
            //for(auto i=posi.begin();i!=posi.end();i++){
            //    printf("%lld ",*i);
            //}
            //printf("\n");
            //printf("nega\n");
            //for(auto i=nega.begin();i!=nega.end();i++){
            //    printf("%lld ",*i);
            //}
            //printf("\n");

            int remain=k;
            int indexP=0,indexN=0;
            ll res=1;
            if(k%2==1){
                res= (res * posi[0])%MOD;
                indexP++;
                remain--;
            }
            for(;remain>1&&indexP<countP-1&&indexN<countN-1;){
                //printf("%d %d %d %lld\n",remain,indexP,indexN,res);
                ll tempP = posi[indexP] * posi[indexP+1];
                ll tempN = nega[indexN] * nega[indexN+1];
                //printf("tempP %lld \ntempN %lld\n",tempP, tempN);
                if(tempP>tempN){
                    res = (res*(tempP % MOD))%MOD;
                    indexP+=2;
                }else{
                    res = (res*(tempN % MOD))%MOD;
                    indexN+=2;
                }
                remain-=2;
            }
            for(;remain>1&&indexP<countP-1;){
                //printf("P %d %d %d %lld\n",remain,indexP,indexN,res);
                ll tempP = posi[indexP] * posi[indexP+1];
                res = (res*(tempP % MOD))%MOD;
                indexP+=2;
                remain-=2;
            }
            for(;remain>1&&indexN<countN-1;){
                //printf("N %d %d %d %lld\n",remain,indexP,indexN,res);
                ll tempN = nega[indexN] * nega[indexN+1];
                res = (res*(tempN % MOD))%MOD;
                indexN+=2;
                remain-=2;
            }
            printf("%lld\n",res);
        }
    }
}








Measured memory_bytes: 7140