#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

struct mint {
    ll x; // typedef long long ll;
    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;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
    mint p(int n, int k) {
        return fact[n]*ifact[n-k];
    }
};


int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> p;
    vector<ll> m;
    vector<ll> z;
    rep(i, n) {
        if (a[i]>=0) p.push_back(a[i]);
        else m.push_back(a[i]);
        z.push_back(abs(a[i]));
    }

    sort(whole(p));
    reverse(whole(p));
    sort(whole(m));
    mint ans = 1;
    if (p.size()==0) {
        if (k%2==1) {
            reverse(whole(m));
        }
        rep(i, k) ans *= m[i];
        cout << ans << endl;
        return 0;
    }
    sort(whole(z));
    reverse(whole(z));
    ll th = z[k-1];
    if (th==0) {
        cout << 0 << endl;
        return 0;
    }
    int ip = 0;
    int im = 0;
    while (ip+im<k && ip<p.size() && p[ip]>=th) {
        ans *= p[ip];
        ip++;
    }
    while (ip+im<k && im<m.size() && abs(m[im])>=th) {
        ans *= m[im];
        im++;
    }
    if (k==n) {
        cout << ans << endl;
        return 0;
    }
    if (im%2==1) {
        if (ip==p.size()) {
            ans /= p[ip-1];
            ans *= m[im];
        }
        else if (im==m.size()) {
            ans /= m[im-1];
            ans *= p[ip];
        }
        else if (ip==0) {
            ans /= m[im-1];
            ans *= p[ip];
        }
        else if (im==0) {
            ans /= p[ip-1];
            ans *= m[im];
        }
        else if (p[ip-1]*p[ip]>m[im-1]*m[im]) {
            ans /= m[im-1];
            ans *= p[ip];
        }
        else {
            ans /= p[ip-1];
            ans *= m[im];
        }
    }

    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9124