#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

ll extGCD(ll a, ll b, ll &x, ll &y){
    if(b == 0){
        x = 1;
        y = 0;
        return a;
    }
    ll g = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return g;
}

ll MOD = 1000000007;

vector<ll> mfact(1,1);

ll minv(ll a){
    ll x;ll y;
    extGCD(a, MOD, x, y);
    if(x<0){
        x+= ((-x)/MOD+1)*MOD;
        x %= MOD;
    }
    return x;
}

ll mpow(ll a,ll b){
    ll res = 1;
    while(b > 0){
        if(b%2==1)res=(res*a)%MOD;
        b/=2;
        a = (a*a)%MOD;
    }
    return res;
}

ll mfactorial(ll a){
    if(mfact.size()-1 >= a)return mfact[a];
    for(ll i = mfact.size();i<=a;i++){
        mfact.push_back((i * mfact[i-1])%MOD);
    }
    return mfact[a];
}

ll mcomb(ll n, ll r){
    return (((mfactorial(n) * minv(mfactorial(r)))%MOD) * minv(mfactorial(n-r)))%MOD;
}

int main(){
    int N,K;
    cin>>N>>K;
    vector<ll> A;
    for(int i = 0;i < N;i++){
        ll _a;cin>>_a;
        A.push_back(_a);
    }
    auto fn = [](int l, int r){
        return abs(l) > abs(r);
    };

    sort(A.begin(), A.end(), fn);
    vector<ll> sumpositive;
    vector<ll> sumnegative;
    vector<ll> poss;
    vector<ll> negs;
    sumpositive.push_back(1);
    sumnegative.push_back(1);
    for(int i = 0;i < N;i++){
        if(A[i] >= 0){
            poss.push_back(A[i]);
            sumpositive.push_back((sumpositive[sumpositive.size()-1] * A[i]) % MOD);
        }else{
            negs.push_back(A[i]);
            sumnegative.push_back((sumnegative[sumnegative.size()-1] * (-A[i])) % MOD);
        }
    }
    ll result = -1;
    //マイナス偶数(+をめざす)
    ll pre = -1;

    for(int minuss = 0;minuss <= sumnegative.size()-1;minuss+=2){
        // cout<<minuss<<endl;
        if(K - minuss >= sumpositive.size())continue;
        if(minuss >= sumnegative.size())break;
        ll r = (sumpositive[K-minuss] * sumnegative[minuss]) % MOD;
        // cout<<r<<endl;
        // cout<<minuss<<endl;
        if(result == -1){
            result = r;
            pre = minuss;
        // cout<<"---"<<endl;
            continue;
        }
        // cout<<poss[K-pre-1] * poss[K-pre-2]<<endl;
        // cout<<negs[minuss-1]*negs[minuss-2]<<endl;
        // cout<<"---"<<endl;
        if(poss[K-pre-1] * poss[K-pre-2] < negs[minuss-1]*negs[minuss-2]){
            result = r;
            pre = minuss;
            continue;
        }

    }
    if(result != -1){
        cout<<result<<endl;
        return 0;
    }
    //マイナス奇数(-を目指す)
    auto fn2 = [](int l, int r){
        return abs(l) < abs(r);
    };

    sort(negs.rbegin(), negs.rend());
    sort(poss.begin(), poss.end());
    for(int i = 0;i < negs.size();i++){
        sumnegative[i+1] = (sumnegative[i] * (-negs[i]))%MOD;
    }
    for(int i = 0;i < poss.size();i++){
        sumpositive[i+1] = (sumpositive[i] * (poss[i]))%MOD;
    }
    pre = -1;
    // cout<<sumnegative.size()<<endl;
    for(int minuss = 1;minuss <= sumnegative.size()-1;minuss+=2){
        // cout<<minuss<<endl;
        if(K - minuss >= sumpositive.size())continue;
        // cout<<"A"<<endl;
        if(minuss >= sumnegative.size())break;
        // cout<<"B"<<endl;
        ll r = (sumpositive[K-minuss] * sumnegative[minuss]) % MOD;
        // cout<<r<<endl;
        // cout<<minuss<<endl;
        if(result == -1){
            result = r;
            pre = minuss;
        // cout<<"---"<<endl;
            continue;
        }
        // cout<<poss[K-pre-1] * poss[K-pre-2]<<endl;
        // cout<<negs[minuss-1]*negs[minuss-2]<<endl;
        // cout<<"---"<<endl;
        if(poss[K-pre-1] * poss[K-pre-2] > negs[minuss-1]*negs[minuss-2]){
            result = r;
            pre = minuss;
            continue;
        }

    }
    cout<<(MOD-result)%MOD<<endl;
    
    
}

Measured memory_bytes: 10368