#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

template<int M>
class ModInt {
   public:
    ll value;
    constexpr ModInt(ll v = 0) { value = v % M; if (value < 0) value += M; }
    constexpr ModInt pow(ll n) const {
        if (!n) return 1;
        ModInt a = pow(n >> 1);
        a *= a;
        if (n & 1) a *= *this;
        return a;
    }
    constexpr ModInt inv() const { return this->pow(M - 2); }
    constexpr ModInt operator + (const ModInt &rhs) const { return ModInt(*this) += rhs; };
    constexpr ModInt operator - (const ModInt &rhs) const { return ModInt(*this) -= rhs; };
    constexpr ModInt operator * (const ModInt &rhs) const { return ModInt(*this) *= rhs; };
    constexpr ModInt operator / (const ModInt &rhs) const { return ModInt(*this) /= rhs; };
    constexpr ModInt &operator += (const ModInt &rhs) { value += rhs.value; if (value >= M) value -= M; return *this; };
    constexpr ModInt &operator -= (const ModInt &rhs) { value -= rhs.value; if (value <  0) value += M; return *this; };
    constexpr ModInt &operator *= (const ModInt &rhs) { value = value * rhs.value % M; return *this; };
    constexpr ModInt &operator /= (const ModInt &rhs) { return (*this) *= rhs.inv(); };
    constexpr bool operator == (const ModInt &rhs) { return value == rhs.value; }
    constexpr bool operator != (const ModInt &rhs) { return value != rhs.value; }
    friend ostream &operator << (ostream &os, const ModInt &rhs) { os << rhs.value; return os; }
};

using mint = ModInt<MOD>;

int main() {
    int N, K; cin >> N >> K;
    vector<ll> neg, pos;
    REP(i, 0, N) {
        int a; cin >> a;
        if (a > 0) pos.push_back(a);
        else if (a < 0) neg.push_back(a);
    }


    int p = pos.size(), n = neg.size();
    // if (p + n < K) {
    //     cout << 0 << endl;
    //     return 0;
    // }

    mint ans = 1;
    int k = K - K % 2;
    int k_rem = K % 2;
    // cout << "k : " << k << " " << k_rem << endl;
    int idxp = 0, idxn = 0;
    if (n - n % 2 + p >= k && p - max(0, (k - (n - n % 2))) >= k_rem) {
        // cout << "### Positive" << endl;
        sort(ALL(pos), greater<>());
        sort(ALL(neg));
        while (K) {
            if (K > 1) {
                if (K % 2 && p - idxp <= 2) {
                    ans *= (mint)neg[idxn++];
                    ans *= (mint)neg[idxn++];
                } else {
                    if (p - idxp >= 2 && n - idxn >= 2) {
                        if (neg[idxn] * neg[idxn + 1] >= pos[idxp] * pos[idxp + 1]) {
                            ans *= (mint)neg[idxn++];
                            ans *= (mint)neg[idxn++];
                        } else {
                            ans *= (mint)pos[idxp++];
                            ans *= (mint)pos[idxp++];
                        }
                    } else if (p - idxp >= 2) {
                        ans *= (mint)pos[idxp++];
                        ans *= (mint)pos[idxp++];
                    } else if (n - idxn >= 2) {
                        ans *= (mint)neg[idxn++];
                        ans *= (mint)neg[idxn++];
                    } else {
                        cout << 0 << endl;
                        return 0;
                    }
                }
                K -= 2;
            } else {
                ans *= (mint)pos[idxp++];
                K--;
            }
        }
    } else {
        // cout << "### Negative" << endl;
        if (p + n < N) {
            cout << 0 << endl;
            return 0;
        } else {
            sort(ALL(pos));
            sort(ALL(neg), greater<>());
            while (K) {
                if (p - idxp > 0 && n - idxn > 0) {
                    if (pos[idxp] > abs(neg[idxn])) {
                        ans *= neg[idxn++];
                    } else {
                        ans *= pos[idxp++];
                    }
                } else if (p - idxp > 0) {
                    ans *= pos[idxp++];
                } else {
                    ans *= neg[idxn++];
                }
                K--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5472