#include <bits/stdc++.h>

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef long long ll;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int mul(int x, int y) {
    int ret = 1LL * x * y % MOD;
    return ret;
}


int main() {

#ifndef ONLINE_JUDGE
    //freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    vector<int> neg, pos;
    int n, k, z = 0;
    cin >> n >> k;

    loop(i, n) {
        int x;
        cin >> x;
        if (x == 0)z++;
        else if (x > 0)pos.pb(x);
        else neg.pb(-x);
    }


    {
        sort(RALL(pos));
        sort(RALL(neg));
        vector<long double> pd, nd;
        pd.pb(0), nd.pb(0);
        for (auto x : pos)pd.pb(pd.back() + log(x));
        for (auto x : neg)nd.pb(nd.back() + log(x));

        bool flag = false;
        long double best = 0;
        range(i, 0, k) {
            if (SZ(pos) >= i && SZ(neg) >= k - i && (k - i) % 2 == 0) {
                flag = true;
                best = max(best, pd[i] + nd[k - i]);
            }
        }

        if (flag) {
            range(i, 0, k) {
                if (SZ(pos) >= i && SZ(neg) >= k - i && (k - i) % 2 == 0 && pd[i] + nd[k - i] == best) {
                    int ans = 1;
                    loop(j, i)ans = mul(ans, pos[j]);
                    loop(j, k - i)ans = mul(ans, -neg[j]);
                    cout << ans << endl;
                    return 0;
                }
            }
        }

        if (z) {
            cout << 0 << endl;
            return 0;
        }
    }

    //solve Min
    {
        sort(ALL(pos));
        sort(ALL(neg));
        vector<long double> pd, nd;
        pd.pb(0), nd.pb(0);
        for (auto x : pos)pd.pb(pd.back() + log(x));
        for (auto x : neg)nd.pb(nd.back() + log(x));

        bool flag = false;
        long double best = 1e18;
        range(i, 0, k) {
            if (SZ(pos) >= i && SZ(neg) >= k - i) {
                flag = true;
                best = min(best, pd[i] + nd[k - i]);
            }
        }

        if (flag) {
            range(i, 0, k) {
                if (SZ(pos) >= i && SZ(neg) >= k - i && pd[i] + nd[k - i] == best) {
                    int ans = 1;
                    loop(j, i)ans = mul(ans, pos[j]);
                    loop(j, k - i)ans = mul(ans, -neg[j]);
                    cout << (ans + MOD) % MOD << endl;
                    return 0;
                }
            }
        }


        assert(false);
    }

    return 0;
}


Measured memory_bytes: 9444