// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using o_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) find_by_order(i)
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vector<ll> ft(1, 1LL);

ll power(ll x, ll y) {
    ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
/*======================================================================*/
bool cmp(int a, int b){
    return abs(a) > abs(b);
}
bool cmp1(int a, int b){
    return abs(a) < abs(b);
}
void solve(){
    int n, k, c = 0, ans;
    cin >> n >> k;
    vi v(n);
    rep(i, 0, n)cin >> v[i], c += (v[i] == 0);
    if(n-c < k){
        cout << 0;
        return;
    }
    if(c)ans = 0;
    sort(all(v), cmp);
    int cunt = 0;
    rep(i, 0, k){
        if(v[i] < 0)cunt++;
    }
    ans = 1;
    rep(i, 0, k)ans = (ans*abs(v[i]))%mod;
    if(cunt%2){
        int mi = 1e10, ma = -1, mi1 = 1e10, ma1 = -1;
        rep(i, 0, k){
            if(v[i] < 0)mi = min(mi, abs(v[i]));
        }
        rep(i, k, n){
            if(v[i] >= 0)ma = max(ma, v[i]);
        }
        rep(i, 0, k){
            if(v[i] >= 0)mi1 = min(mi1, abs(v[i]));
        }
        rep(i, k, n){
            if(v[i] < 0)ma1 = max(ma1, abs(v[i]));
        }
        if(ma != -1 and mi1 != 1e10 and ma1 != -1){
            if(mi*ma1 > mi1*ma){
                ans = ((ans*ma1)%mod)*mod_in(mi1);
            }
            else {
                ans = ((ans*ma)%mod)*mod_in(mi);
            }
        }
        else if(ma != -1){
            ans = ((ans*ma)%mod)*mod_in(mi);
        }
        else if(ma1 != -1 and mi1 != 1e10){
            ans = ((ans*ma1)%mod)*mod_in(mi1);
        }
        else {
            sort(all(v), cmp1);
            ans  = 1;
            rep(i, 0, k)ans= (abs(v[i])*ans)%mod;
            ans = (mod-ans)%mod;
        }
    }
    cout << ans%mod;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 4788