#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
const int mod = 1000000007;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
};
int n,k;
int main(){
    cin >> n >> k;
    ve<int> p,m,z;
    rep(i,n){
        int a;
        cin >> a;
        if(a < 0) m.push_back(-a);
        if(a == 0) z.push_back(a);
        if(a > 0) p.push_back(a);
    }
    sort(p.rbegin(), p.rend());
    sort(m.rbegin(), m.rend());
    int s = (int)p.size();
    int t = (int)m.size();
    if(z.empty()){
        if(s > 0){
            if(s+t == k){
                mint ans = mint(1);
                rep(i,s) ans *= p[i];
                rep(i,t) ans *= -m[i];
                cout << ans.x << endl;
                return 0;
            }
            else{
                mint ans = mint(1);
                if(k%2 == 1){
                    ans *= p[0];
                    k--;
                    s--;
                    p.erase(p.begin());
                }
                ve<ll> x;
                for(int i = 0;  i+1<s; i += 2)
                    x.push_back((ll)p[i]*p[i+1]);
                for(int i = 0; i+1<t; i += 2)
                    x.push_back((ll)m[i]*m[i+1]);
                sort(x.rbegin(), x.rend());
                rep(i,k/2) ans *= mint(x[i]);
                cout << ans.x << endl;
                return 0;
            }
        }
        if(s == 0){
            if(k%2 == 0){
                mint ans = mint(1);
                rep(i,k) ans *= m[i];
                cout << ans.x << endl;
                return 0;
            }else{
                mint ans = mint(1);
                rep(i,k) ans *= -m[t-1-i];
                cout << ans.x << endl;
                return 0;
            }
        }
    }else{
        if(s > 0){
            if(s+t < k){
                cout << 0 << endl;
                return 0;
            }
            if(s+t == k){
                if(t % 2 == 0){
                    mint ans = mint(1);
                    rep(i,s) ans *= p[i];
                    rep(i,t) ans *= m[i];
                    cout << ans.x << endl;
                    return 0;
                }else{
                    cout << 0 << endl;
                    return 0;
                }
            }if(s+t > k){
                mint ans = mint(1);
                if(k%2 == 1){
                    ans *= p[0];
                    k--;
                    s--;
                    p.erase(p.begin());
                }
                ve<ll> x;
                for(int i = 0; i+1<s; i += 2)
                    x.push_back((ll)p[i]*p[i+1]);
                for(int i = 0; i+1<t; i += 2)
                    x.push_back((ll)m[i]*m[i+1]);
                sort(x.rbegin(), x.rend());
                rep(i,k/2) ans *= mint(x[i]);
                cout << ans.x << endl;
                return 0;
            }
        }
        if(s == 0){
            if(t>=k){
                if(k%2 == 0){
                    mint ans = mint(1);
                    rep(i,k) ans *= m[i];
                    cout << ans.x << endl;
                    return 0;
                }
                if(k%2 == 1){
                    cout << 0 << endl;
                }
            }
            if(t < k){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 5640