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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

const lint mod = MOD;
class mint{
    public:
        long long x;

    constexpr mint(long long _x = 0) : x((_x%mod+mod)%mod) {}
    constexpr mint operator-() const{
        return mint(-x);
    }
    constexpr mint& operator+=(const mint& a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator-=(const mint& a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator*=(const mint& a){
        (x *= a.x) %= mod;
        return *this;
    }
    constexpr mint operator+(const mint& a) const{
        mint res(*this);
        return res+=a;
    }
    constexpr mint operator-(const mint& a) const{
        mint res(*this);
        return res-=a;
    }
    constexpr mint operator*(const mint& a) const{
        mint res(*this);
        return res*=a;
    }
    constexpr mint pow(long long x) const{
        if(!x) return 1;
        mint a = pow(x>>1);
        a *= a;
        if(x&1) a *= *this;
        return a; 
    }
    constexpr mint inv() const{
        return pow(mod-2);
    }
    constexpr mint& operator/=(const mint& a){
        return (*this) *= a.inv();
    }
    constexpr mint operator/(const mint& a) const{
        mint res(*this);
        return res/=a;
    }
    friend istream& operator>>(istream& is, mint& m){
        long long x; is >> x; m = x;
        return is;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x; return os;
    }
};

int main(){
    int n,k; cin>>n>>k;
    vector<lint> a(n); rep(i, n) cin >> a[i];

    sort(all(a), [](lint l, lint r){
        return abs(l) > abs(r);
    });

    int p=0, q=0, r=0; mint tmp = 1;
    lint b=INF, c=INF, d=INF, e=INF;
    rep(i, k){
        tmp *= abs(a[i]);
        if(a[i] > 0){
            p++; d = a[i];
        }
        else if(a[i] < 0){
            q++; e = a[i];
        }
        else r++;
    }

    if(q % 2 == 1){
        repp(i, k, n){
            if(a[i] > 0 && b == INF) b = a[i];
            else if(a[i] < 0 && c == INF) c = a[i];
        }

        if((b==INF || e==INF) && (c==INF || d==INF)){
            if(r) tmp = 0;
            else{
                tmp = 1;
                rep(i, k) tmp *= abs(a[n-1-i]);
                tmp = -tmp;
            }
        }
        else if(b==INF || e==INF){
            tmp *= abs(c);
            tmp /= d;
        }
        else if(c==INF || d==INF){
            tmp *= b;
            tmp /= abs(e);
        }
        else{
            if(abs(b*d) >= abs(c*e)){
                tmp *= b;
                tmp /= abs(e);
            }else{
                tmp *= abs(c);
                tmp /= d;
            }
        }
    }

    out(tmp);
}

Measured memory_bytes: 4764