//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

[[maybe_unused]] constexpr ll LL_MAX = numeric_limits<ll>::max();
[[maybe_unused]] constexpr ll LL_MIN = numeric_limits<ll>::min();
[[maybe_unused]] constexpr ull ULL_MAX = numeric_limits<ull>::max();

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

template <typename T>
void chmin(T& x, T y) {
    x = min(x, y);
}

template <typename T>
void chmax(T& x, T y) {
    x = max(x, y);
}

ll csum(ll x, ll y) {
    if (x > 0 && y > 0 && x > LL_MAX - y) {
        return LL_MAX;
    }
    if (x < 0 && y < 0 && x < LL_MIN - y) {
        return LL_MIN;
    }
    return x + y;
}

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

struct Mod {
    static uint64_t PRIME;
    struct LocalPrime {
        uint64_t backup;
        LocalPrime(uint64_t prime) { backup = exchange(Mod::PRIME, prime); }
        ~LocalPrime() { Mod::PRIME = backup; }
    };
    uint64_t value = 0;
    Mod()
    : value(0) {}
    Mod(ll v) {
        if (v >= 0) {
            value = v % PRIME;
        } else {
            value = PRIME - (-v) % PRIME;
        }
    }
    Mod operator+(const Mod& rhs) const { return Mod(*this) += rhs; }
    Mod& operator+=(const Mod& rhs) {
        value += rhs.value;
        if (value >= PRIME) {
            value -= PRIME;
        }
        return *this;
    }
    Mod operator-(const Mod& rhs) const { return Mod(*this) -= rhs; }
    Mod& operator-=(const Mod& rhs) {
        if (value < rhs.value) {
            value += PRIME;
        }
        value -= rhs.value;
        return *this;
    }
    Mod operator*(const Mod& rhs) const { return Mod(*this) *= rhs; }
    Mod& operator*=(const Mod& rhs) {
        value = (value * rhs.value) % PRIME;
        return *this;
    }
    Mod inv() const { return power(*this, PRIME - 2); }
    Mod operator/(const Mod& rhs) const { return Mod(*this) /= rhs; }
    Mod& operator/=(const Mod& rhs) {
        *this *= rhs.inv();
        return *this;
    }
    static Mod power(Mod rhs, ll exp) {
        Mod ans = 1;
        while (exp > 0) {
            if (exp % 2) {
                ans *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return ans;
    }
};
uint64_t Mod::PRIME = 1000000007;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,0,N) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    vector<ll> negs;
    vector<ll> geqs;
    rep(i,0,N) {
        if (A[i] < 0) {
            negs.push_back(A[i]);
        } else {
            geqs.push_back(A[i]);
        }
    }
    sort(negs.begin(), negs.end());
    sort(geqs.begin(), geqs.end());
    auto accum = [](const vector<ll>& xs) -> vector<Mod> {
        vector<Mod> ans(xs.size() + 1);
        ans[0] = 1;
        rep(n,1,xs.size()+1) {
            ans[n] = ans[n-1] * xs[n-1];
        }
        return ans;
    };
    vector<Mod> negs_left = accum(negs);
    reverse(negs.begin(), negs.end());
    vector<Mod> negs_right = accum(negs);
    reverse(negs.begin(), negs.end());
    
    vector<Mod> geqs_left = accum(geqs);
    reverse(geqs.begin(), geqs.end());
    vector<Mod> geqs_right = accum(geqs);
    reverse(geqs.begin(), geqs.end());

    ll L = negs.size();
    ll M = geqs.size();
    rep(n,0,L+1) {
        ll m = K - n;
        if (!(n % 2 == 0)) {
            continue;
        }
        if (!(n <= K)) {
            continue;
        }
        if (!(m <= M)) {
            continue;
        }
        Mod now = negs_left[n] * geqs_right[m];
        bool ret_ans = false;
        if (!(n + 2 <= L)) {
            ret_ans = true;
        } else if (m < 2) {
            ret_ans = true;
        } else if (negs[n] * negs[n+1] < geqs[M-m] * geqs[M-m+1]) {
            ret_ans = true;
        }
        if (ret_ans) {
            cout << now.value << endl;
            return 0;
        }
    }
    rep(n,0,L+1) {
        ll m = K - n;
        if (!(n % 2 == 1)) {
            continue;
        }
        if (!(n <= K)) {
            continue;
        }
        if (!(m <= M)) {
            continue;
        }
        Mod now = negs_right[n] * geqs_left[m];
        bool ret_ans = false;
        if (!(n + 2 <= L)) {
            ret_ans = true;
        } else if (m < 2) {
            ret_ans = true;
        } else if (negs[L-n-1] * negs[L-n-2] > geqs[m-1] * geqs[m-2]) {
            ret_ans = true;
        }
        if (ret_ans) {
            cout << now.value << endl;
            return 0;
        }
    }
}


/*
 
 4 2
 1 2 -3 -4
 
 4 3
 1 2 -3 -4
 
 4 1
 1 2 -3 -4
 
 4 4
 1 2 -3 -4
 
 4 4
 1 -2 -3 -4
 
 */


Measured memory_bytes: 9084