#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    ll res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

ll f[200001];
 
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
 
 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
 
ll min(ll a,ll b)
{
    if(a<b)
        return a;
    return b;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),k=nxt();
    vector <ll> pos,zero,neg;
    for(int i=0;i<n;i++)
    {
        ll x=nxt();
        if(x>0)
            pos.push_back(x);
        else if(x<0)
            neg.push_back(-x);
        else
            zero.push_back(x);
    }
    sort(all(pos),greater<ll>());
    sort(all(neg),greater<ll>());

    ll mod=1e9+7;
    if(k==n)
    {
       ll test=1;
        for(int i=0;i<neg.size();i++)
            (test*=neg[i])%=mod;
        for(int i=0;i<pos.size();i++)
            (test*=pos[i])%=mod;
        for(int i=0;i<zero.size();i++)
            (test*=zero[i])%=mod;
        if(neg.size()%2)
            test=(mod-test)%mod;
        cout<<test<<endl;
        return 0; 
    }
    if(k%2&&!pos.size()&&!zero.size())
    {
        ll test=1;
        for(int i=neg.size()-1;i>neg.size()-k-1;i--)
            (test*=neg[i])%=mod;
        test=(mod-test)%mod;
        cout<<test<<endl;
        return 0;
    }

    if(k%2&&!pos.size())
    {
        cout<<"0"<<endl;
        return 0;
    }

    ll ans;
    if(zero.size())
        ans=0;
    vector <ll> pos2(pos.size()+1,1),neg2(neg.size()+1,1);
    for(int i=1;i<=pos.size();i++)
        (pos2[i]=pos2[i-1]*pos[i-1])%=mod;
    for(int i=1;i<=neg.size();i++)
        (neg2[i]=neg2[i-1]*neg[i-1])%=mod;
    bool flag=0;
    for(int i=0;i<=min(neg.size(),k);i+=2)
    {
        if(k-i>pos.size()){
                continue;
        }
        else
        {
            if(!flag)
            {
                flag=1;
                ans=(neg2[i]*pos2[k-i])%mod;
            }
            else{
                if(pos[k-i+1]*pos[k-i]>=neg[i-1]*neg[i-2])
                    break;
                ans=(neg2[i]*pos2[k-i])%mod;
            }
        }

    }

    cout<<ans<<endl;


    return 0;   
}


 
 


Measured memory_bytes: 6324