#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

constexpr int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return x ? mod - x : 0;}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}

  friend ostream& operator << (ostream& os, const mint& m) noexcept {
    return os << m.x;
  }

  friend istream& operator<< (istream& is, mint& m) noexcept {
    return is >> m.x;
  }
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  vector<ll> pos;
  vector<ll> neg;
  ll num_zero = 0;

  rep(i, n) {
    cin >> a[i];
    if (a[i] == 0) num_zero++;
    else if (a[i] > 0) pos.push_back(a[i]);
    else neg.push_back(a[i]);
  }

  sort(pos.rbegin(), pos.rend());
  sort(neg.begin(), neg.end());

  if (n == k) {
    mint ans = 1;
    rep(i, n) ans *= a[i];
    cout << ans << endl;
    return 0;
  }

  // 必ず 0 が要る場合
  if (pos.size() + neg.size() < k) {
    cout << 0 << endl;
    return 0;
  }

  if (pos.size() == 0 && k % 2 == 1 && num_zero > 0) {
    cout << 0 << endl;
    return 0;
  }

  // neg を奇数個選ぶ
  if (pos.size() == 0 && num_zero == 0 && k % 2 == 1) {
    mint ans = 1;
    sort(neg.rbegin(), neg.rend());
    rep(i, k) ans *= neg[i];
    cout << ans << endl;
    return 0;
  }

  mint ans = 1;
  int idx_p = 0, idx_n = 0;

  if (k % 2 == 1 && !pos.empty()) {  // pos 1個とる
    reverse(ALL(pos));
    ans *= pos.back();
    pos.pop_back();
    reverse(ALL(pos));
    k--;
  }

  // cerr << "hoge" << endl;

  for (int i = 0; i < k/2; i++) {
    if (idx_p + 1 >= pos.size() && idx_n + 1 < neg.size()) {
      // cerr << "foo" << endl;
      ans *= (neg[idx_n] * neg[idx_n + 1]);
      idx_n += 2;
    } else if (idx_p + 1 < pos.size() && idx_n + 1 >= neg.size()) {
      // cerr << "bar" << endl;
      ans *= (pos[idx_p] * pos[idx_p + 1]);
      idx_p += 2;
    } else {
      // cerr << "baz" << endl;
      if (pos[idx_p] * pos[idx_p + 1] >= neg[idx_n] * neg[idx_n + 1]) {
        // cerr << "baz1" << endl;
        ans *= (pos[idx_p] * pos[idx_p + 1]);
        idx_p += 2;
      } else {
        // cerr << "baz2" << endl;
        ans *= (neg[idx_n] * neg[idx_n + 1]);
        idx_n += 2;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6896