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

#define IOS {ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);}
#define pb push_back
#define nl cout << "\n"
#define endl "\n"
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c.size())
#define mp make_pair
#define mt make_tuple
#define get(x , c) get<x>(c)
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpll vector<pll>
#define f first
#define s second

inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a; a%=b;return gcd(b,a);}
ll power(ll x, ll y){if(y == 0) return 1; ll a = power(x,y/2);if (y % 2 == 0) return a * a; else return x * a * a; }
ll powermod(ll x, ll ex , ll md) {ll ans = 1ll;while (ex > 0) {if (ex & 1ll) ans = (ans * x) % md; ex >>= 1ll;x = (x * x) % md;}return ans;}

const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const ld PI = acos(-1);
const ld eps = 1e-9;

const ll N = 2e5 + 11;
ll n , k , a[N];
ll ans(ll a[] , ll n, ll k){
    sort(a , a + n , greater<ll>());
    if(a[0]<0){
        ll p = 1 , x = 1;
        if(k&1){
            rep(i ,k){
                p *= a[i];
                p %= mod;
            }
        }
        else{
            rep(i , k){
                p *= a[n - 1 - i];
                p %= mod;
            }
        }
        return (p + mod)%mod;
    }
    if(n == k){
        ll p = 1;
        ll x = 1;
        rep(i , n){
            p *= a[i];
            p %= mod;
        }
        return (p + mod)%mod;
    }
    vll pos , neg;
    rep(i , n){
        if(a[i]>=0) pos.pb(a[i]);
        else neg.pb(-a[i]);
    }
    sort(all(pos) , greater<ll>());
    sort(all(neg) , greater<ll>());
    vll pfxpos(sz(pos) + 1) , pfxneg(sz(neg) + 1);
    pfxpos[0] = pfxneg[0] = 1;
    rep(i , sz(pos)) pfxpos[i + 1] = ( pfxpos[i]%mod * pos[i]%mod )%mod;
    rep(i , sz(neg)) pfxneg[i + 1] = ( pfxneg[i]%mod * neg[i]%mod )%mod;
    pfxpos[0] = pfxneg[0] = 1;
    ll ans = 0;
    /*
    rep(i ,sz(pos)) cout << pos[i] << " "
    ;nl;rep(i , sz(neg)) cout << neg[i] << " ";
    nl;
    */
    for(ll i = 0 ; i <= min(k , sz(neg)) ; i += 2){
        ll p1 , p2;
        ll l1 = i , l2 = k - i;
        if(i == 0 && k - i <= sz(pos)) ans = pfxpos[k];
        else{
            p1 = neg[i - 1] * neg[i - 2];
            if(k - i >= 0 && k - i <= sz(pos)){
                // cout << i << ": " << k - i <<" " << p1 <<" " << p2 << endl;nl;
                if(k - i >= 0 && k - i < sz(pos)){
                     p2 = pos[k - i + 1] * pos[k - i];
                    if(p1 < p2) break;
                    else{
                        ans = pfxneg[i];
                        ans *= pfxpos[k - i];
                        ans %= mod;
                    }
                }
                else{
                    ans = pfxneg[i];
                    if(k - i >= 0 && k - i <= sz(pos)) ans *= pfxpos[k - i];
                    ans %= mod;
                }
            }
        }
        // cout << " ans " << ans << " i " << i << " " << k - i << endl;
    }
    return ans;
}
void solve(){
    cin >> n >> k;
    rep(i , n) cin >> a[i];
    cout << ans(a , n , k) ;
}
int main(){
    IOS;
    cout << fixed << setprecision(20);
    ll NTC = 1;
    // cin >> NTC;
    ll PTC = 0;
    while(PTC++ < NTC){
        // cout << "Case #" << PTC << ":" << ' ';
        solve();
    }
    // cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 7868