#include <bits/stdc++.h>

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_K = 200005;
const int MAX_N = 200005;
int N, K;
int A[MAX_N];

struct ModInt {
  static void setMod(int m) {
    mod = m;
  }

  ModInt(int val = 0) : val(val%mod) {}

  inline const ModInt operator + (const ModInt& rhs) const {
    return ModInt((this->val + rhs.val) % mod);
  }

  inline const ModInt operator - (const ModInt& rhs) const {
    return ModInt((this->val + mod - rhs.val) % mod);
  }

  inline const ModInt operator * (const ModInt& rhs) const {
    return ModInt((this->val * ((mod+rhs.val)%mod)) % mod);
  }

  inline ModInt& operator += (const ModInt& rhs) {
    this->val = (this->val + rhs.val) % mod;
    return *this;
  }

  inline ModInt& operator -= (const ModInt& rhs) {
    this->val = (this->val + mod - rhs.val) % mod;
    return *this;
  }

  inline ModInt& operator *= (const ModInt& rhs) {
    this->val = (this->val * ((rhs.val+mod)%mod)) % mod;
    return *this;
  }

  int val;
  static int mod;
};
int ModInt::mod = 1000000007;

vector<int> mA, pA;
bool zeroFlag = false;

int solveBig() {
  sort(begin(mA), end(mA));
  sort(begin(pA), end(pA), greater<int>());
  int mIndex = 0, pIndex = 0;
  int k = 0;
  ModInt ans = 1;
  while(k < K) {
    if (k+2 <= K) {
      if (mIndex+2 <= mA.size() && pIndex+2 <= pA.size()) {
        int l = mA[mIndex] * mA[mIndex+1], r = pA[pIndex] * pA[pIndex+1];
        if (l < r) {
          ans *= r; pIndex += 2;
        } else {
          ans *= l; mIndex += 2;
        }
        k += 2;
      } else {
        if (mIndex+2 <= mA.size()) {
          ans *= mA[mIndex] * mA[mIndex+1];
          mIndex += 2;
        } else if (pIndex+2 <= pA.size()) {
          ans *= pA[pIndex] * pA[pIndex+1];
          pIndex += 2;
        } else {
          ans *= pA[pIndex] * mA[mIndex];
        }
        k += 2;
      }
    } else { //RE point
      ans *= pA[pIndex++];
      k++;
    }
  }
  return ans.val;
}

int solveMin() {
  if (zeroFlag) {
    return 0;
  }
  sort(begin(mA), end(mA), greater<int>());
  sort(begin(pA), end(pA));
  ModInt ans = 1;
  int mIndex = 0, pIndex = 0;
  REP(k,K) {
    if (mIndex < mA.size() && pIndex < pA.size()) {
      int l = mA[mIndex], r = pA[pIndex];
      if (abs(l) < abs(r)) {
        ans *= l;
        mIndex++;
      } else {
        ans *= r;
        pIndex++;
      }
    } else if (mIndex < mA.size()) {
      ans *= mA[mIndex++];
    } else {
      ans *= pA[pIndex++];
    }
  }
  return ans.val;
}

signed main()
{
  cin >> N >> K;
  REP(n,N) {
    cin >> A[n];
  }

  sort(A, A+N);
  REP(n,N) {
    if (A[n] < 0) {
      mA.push_back(A[n]);
    } else if (0 < A[n]) {
      pA.push_back(A[n]);
    } else {
      zeroFlag = true;
    }
  }

  if (mA.size() + pA.size() < K) {
    cout << 0 << endl;
    return 0;
  }

  if (mA.size()%2 == 0) {
    if (K%2 == 0) {
      cout << solveBig() << endl;
      return 0;
    } else {
      if (pA.size()%2 == 1) {
        cout << solveBig() << endl;
        return 0;
      }
      int S = mA.size() + (int)pA.size()-1;
      if (K <= S && 1 <= pA.size()) {
        cout << solveBig() << endl;
        return 0;
      }
      cout << solveMin() << endl;
      return 0;
    }
  } else {
    if (K%2 == 0) {
      int S = (int)mA.size()-1 + (int)pA.size()-(pA.size()%2);
      if (K <= S && 1 <= mA.size() && pA.size()%2 <= pA.size()) {
        cout << solveBig() << endl;
        return 0;
      }
      cout << solveMin() << endl;
      return 0;
    } else {
      int S = (int)mA.size()-1 + (int)pA.size()-(pA.size()%2 == 0 ? 1 : 0);
      if (K <= S && 1 <= mA.size() && (pA.size()%2 == 0 ? 1 : 0) <= pA.size()) {
        cout << solveBig() << endl;
        return 0;
      }
      cout << solveMin() << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 7092