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

#define int           long long 
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v){
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}

const int M = 1e9+7;

void solve(int &test) {
    int n, k;
    cin >> n >> k;
    vi po, ne;
    int mul = 1;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        mul *= x;
        mul %= M;
        if(x < 0)ne.pb(-x);
        else po.pb(x);
    }
    sort(rall(po));
    sort(rall(ne));
    bool f = 0;
    for(int i = 0; i <= k; i += 2){
        if(i <= si(ne) && k-i <= si(po)){
            f = 1; break;
        }
    }
    if(!f){
        if(si(ne) == n){
            mul = 1;
            reverse(all(ne));
            for(int i = 0; i < k; i++){
                mul *= -ne[i];
                mul %= M;
            }
        }
        cout << (mul+M)%M << endl;
    } else {
        if(si(ne)%2)ne.pop_back();
        while(si(ne) > k){
            ne.pop_back();
            ne.pop_back();
        }
        k -= si(ne);
        int cur = k;
        for(int j = si(ne)-2; j >= 0 && si(po) > cur+1; j -= 2){
            if(ne[j]*ne[j+1] < po[cur]*po[cur+1]){
                ne.pop_back();
                ne.pop_back();
                cur += 2;
            } else break;
        }
        int ans = 1;
        for(auto u : ne){
            ans *= u;
            ans %= M;
        }
        for(int i = 0; i < cur; i++){
            ans *= po[i];
            ans %= M;
        }     
        cout << ans << endl;
    }
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;

    start = clock(); 

    cout << fixed << setprecision(2);
    
   
     
    for(int i = 1; i <= t; ++i){
        solve(i);
    }
    cerr << time(start);
    return 0;
}

Measured memory_bytes: 5576