#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

const ll mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  std::vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll N, K;
ll A[200010];
std::vector<ll> ps, ns;
mint pprod[200010], nprod[200010];

int main()
{
  std::cin >> N >> K;

  rep( i, N ) {
    std::cin >> A[i];

    if( A[i] > 0 )
      ps.emplace_back( A[i] );
    else if( A[i] < 0 )
      ns.emplace_back( -A[i] );
  }

  if( ps.size()+ns.size() < K ) {
    std::cout << 0 << std::endl;

    return 0;
  }

  if( N == K ) {
    mint prod = 1;

    rep( i, N )
      prod *= A[i];

    std::cout << prod.x << std::endl;

    return 0;
  }

  std::sort( rall(ps) );
  std::sort( rall(ns) );

  ll p = K-1;
  ll nidx = 0;
  mint ans = 1;

  if( ps.size() >= K ) {
    rep( i, K )
      ans *= ps[i];
  } else {
    ll psz = ps.size();

    if( (K-psz)&1 ) {
      if( ps.empty() ) {
        mint prod = 1;

        rep( i, K )
          prod *= ns[ns.size()-1-i];

        prod *= -1;

        if( N-ns.size()-ps.size() >= 1 )
          prod = 0;

        std::cout << prod.x << std::endl;

        return 0;
      }

      --psz;
    }

    if( K-psz <= 0 ) {
      std::cout << 0 << std::endl;

      return 0;
    }

    rep( i, psz )
      ans *= ps[i];
    rep( i, K-psz )
      ans *= ns[i];

    p = psz-1;
    nidx = K-psz;
  }

  while( p-1 >= 0 && nidx+1 < ns.size() && ps[p]*ps[p-1] <= ns[nidx]*ns[nidx+1] ) {
    if( ps[p]*ps[p-1] < ns[nidx]*ns[nidx+1] ) {
      ans /= ps[p];
      ans /= ps[p-1];
      ans *= ns[nidx+1];
      ans *= ns[nidx];
    }

    p -= 2;
    nidx += 2;
  }

  std::cout << ans.x << std::endl;

  return 0;
}

Measured memory_bytes: 9832