/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto o(C *x)->decltype(os << *x, 0);
template<class C> static char o(...);
template<class C> typename enable_if<sizeof o<C>(0)!=1,Dbg&>::type operator<<(const C &x) {os<<x; return *this;}
template<class C> Dbg &dump(C b, C e) {
    for (struct{C i;int j;} i={(*this<<"\n[",b),0}; i.i!=e and i.j<26; i.i++, i.j++) *this<<", "+2*(i.i==b)<<*i.i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof o<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator<<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator<<(const pair<B, C> &x) {return *this<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 200005;

template<class C, class D> C& operator +=(C &x, const D &y) { return x = x+y; }//{
template<class C, class D> C& operator -=(C &x, const D &y) { return x = x-y; }
template<class C, class D> C& operator *=(C &x, const D &y) { return x = x*y; }
template<class C, class D> bool operator ==(const C &ls, const D &rs) { return !(ls<rs or rs<ls); }
template<class C, class D> bool operator !=(const C &ls, const D &rs) { return !(rs==ls); }
template<class C, class D> bool operator >(const C &ls, const D &rs) { return (rs<ls); }
template<class C, class D> bool operator <=(const C &ls, const D &rs) { return !(rs<ls); }
template<class C, class D> bool operator >=(const C &ls, const D &rs) { return !(ls<rs); }

struct Int// Make sure to not do any operation with non-modded(except *, which must be int, *1 to mod forcefully)
{
    int x;
    Int() = default;
    Int(const int &rs) : x(rs + (rs>=0 ? 0 : inf)) {};
    Int operator -() { return inf-*this; }
    // Int operator ~() = delete;
    Int operator ~() { return power(*this, inf-2); }
    Int operator +(const Int &rs) const { return x+rs.x>=inf ? x+rs.x-inf : x+rs.x; }
    Int operator -(const Int &rs) const { return x-rs.x<0 ? x-rs.x+inf : x-rs.x; }
    Int operator *(const Int &rs) const { return int(x*ll(rs.x)%inf); }
    Int operator <<(const int &rs) { return rs==1 ? *this+*this : *this*Int{1<<rs}; }
    Int& operator <<=(const int &rs) { return *this = *this<<rs; }
    Int& operator >>=(const int &rs) { return x>>=rs, *this; }  // only for power()
    Int& operator ++() { return *this += 1; }
    Int& operator --() { return *this -= 1; }
    Int operator ++(int) { Int ret = x; ++*this; return ret; }
    Int operator --(int) { Int ret = x; --*this; return ret; }
    friend istream& operator >>(istream &is, Int &rs) { return is>>rs.x; }
    friend ostream& operator <<(ostream &os, const Int &rs) { return os<<rs.x; }
    friend Int operator +(const Int &ls, const int &rs) { return ls+Int(rs); }
    friend Int operator +(const int &ls, const Int &rs) { return Int(ls)+rs; }
    friend Int operator -(const Int &ls, const int &rs) { return ls-Int(rs); }
    friend Int operator -(const int &ls, const Int &rs) { return Int(ls)-rs; }
    friend Int operator *(const Int &ls, const int &rs) { return ls*Int(rs); }
    friend Int operator *(const int &ls, const Int &rs) { return Int(ls)*rs; }
    bool operator <(const Int &rs) const { return x<rs.x; }
    friend bool operator <(const int &ls, const Int &rs) { return ls<rs.x; }
    friend bool operator <(const Int &ls, const int &rs) { return ls.x<rs; }
};

Int operator""_i(unsigned long long x) { return {int(x)}; }//}

int n, K;
pair<int, int> a[mxn];

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    cin >> n >> K;
    int cntNeg = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        cntNeg += x < 0;
        a[i] = {abs(x), x/abs(x)};
    }
    if ((cntNeg==n and (K&1)) or (K==n)) {
        sort(a, a+n);
        Int ans = 1;
        for (int i = 0; i < K; i++) {
            ans *= a[i].second*a[i].first;
        }
        return cout << ans << '\n', 0;
    }
    sort(a, a+n, greater<pair<int, int>>());
    if (a[K-1].second == 0) return cout << "0\n", 0;

    cntNeg = 0;
    int lstPos = -1, lstNeg = -1;
    for (int i = 0; i < K; i++) {
        cntNeg += a[i].second == -1;
        if (a[i].second == 1) lstPos = i;
        else lstNeg = i;
    }
    if (!(cntNeg&1)) {
        Int ans = 1;
        for (int i = 0; i < K; i++) {
            ans *= a[i].second*a[i].first;
        }
        return cout << ans << '\n', 0;
    }
    assert(lstNeg != -1);
    int nxtNonNeg = -1, nxtNonPos = -1;
    for (int i = K; i <= n-1; i++) {
        if(a[i].second!=-1) {
            nxtNonNeg = i;
            break;
        }
    }
    for (int i = K; i <= n-1; i++) {
        if (a[i].second!=1) {
            nxtNonPos = i;
            break;
        }
    }//bug(a, lstPos, lstNeg, nxtNonNeg, nxtNonPos);
    Int ans = 1;
    int sign = 1;
    if (nxtNonPos==-1 or lstPos==-1 or (nxtNonNeg!=-1 and a[nxtNonNeg].first*ll(a[lstPos].first) >= a[nxtNonPos].first*ll(a[lstNeg].first))) {
        for (int i = 0; i < K; i++) {
            if (i != lstNeg) sign*=a[i].second, ans *= a[i].second*a[i].first;
        }
        sign*=a[nxtNonNeg].second, ans *= a[nxtNonNeg].second*a[nxtNonNeg].first;
    } else {
        for (int i = 0; i < K; i++) {
            if (i != lstPos) sign*=a[i].second, ans *= a[i].second*a[i].first;//bug(ans);
        }
        sign*=a[nxtNonPos].second, ans *= a[nxtNonPos].second*a[nxtNonPos].first;//bug(ans);
    }
    if (sign==-1) {
        sort(a, a+n);
        ans = 1;
        for (int i = 0; i < K; i++) {
            ans *= a[i].second*a[i].first;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 5148