#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

template<class T> ostream& operator<<(ostream &os, vector<T> V){os << "[ "; for(auto v  : V) os << v << " "; return os << " ]";}
template<class T> ostream& operator<<(ostream &os, set<T> V){os << "[ "; for(auto v  : V) os << v << " "; return os << " ]";}
template<class T , class R > ostream& operator<<(ostream &os, map<T , R> V){os << "[ "; for(auto v  : V) os << "(" << v.first << ":" << v.second << ")"; return os << " ]";}
template<class T , class R > ostream& operator<<(ostream &os, pair<T , R> V){return os << "(" << V.first << "," << V.second << ")";}

#define cerr cout
#ifdef LOCAL
    #define TRACE
#endif
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){cerr << "T->";cerr << name << " : " << arg1 << endl;}
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){cerr << "T->";const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | "; __f(comma+1, args...);}
    clock_t clk=clock();
    #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
    #define trace(...);
    #define checktime();
#endif
/*---------------------------Defines----------------------*/
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long int ll;
typedef long double ld;

#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<"\n"
#define d2(x,y) cout<<(x)<<" "<<(y)<<"\n"
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<"\n"
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<"\n"
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<"\n"
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<"\n"
// Use max({a,b,c,d,....}) instead
// #define max3(a,b,c) max(max((a),(b)),(c))
// #define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))

#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vbl vector<bool>
#define vvll vector<vll>
#define vld vector<ld>
#define vb vector<bool>
#define vc vector<char>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
/*-----------------------Modular Arithmetic---------------*/
inline ll add(ll x,ll y,ll mod){x+=y; if(x>=mod) return x-mod; return x;}
inline ll sub(ll x,ll y,ll mod){x-=y; if(x<0) return x+mod; return x;}
inline ll mul(ll x,ll y,ll mod){return (x*1ll*y)%mod;}
inline ll power(ll x,ll y,ll mod){ll ans=1; while(y){if(y&1) ans=mul(ans,x,mod); x=mul(x,x,mod); y>>=1;} return ans;}
inline ll inv(ll x,ll mod){return power(x,mod-2,mod);}
/*-----------------------------Code begins----------------------------------*/

const ll M1=1e9+7,M2=998244353;
const ll N=1e5+100;

void pre(){
    
}

void solve(){
    ll n,k;cin>>n>>k;
    vpll a(n);
    ll pos=0;
    for(ll i=0;i<n;i++){
        ll x;cin>>x;
        if(x>=0) a[i]={x,1};
        else a[i]={-x,-1};

        if(x>=0) pos++;
    }
    sort(all(a));reverse(all(a));
    ll neg=0,ans=1;
    ll ln=-1,lp=-1;
    for(ll i=0;i<k;i++){
        ans=mul(ans,a[i].F*a[i].S,M1);
        if(a[i].S==-1) neg++;

        if(a[i].S==1) lp=i;
        else ln=i;
    }
    pll p1={-1,-1},p2={-1,-1};
    if(neg%2){
        for(ll i=k;i<n;i++){
            if(a[i].S==1){
                if(p1.F==-1&&p1.S==-1){
                    if(ln==-1) continue;
                    p1.F=a[i].F;
                    p1.S=a[ln].F;
                }
            }else{
                if(p2.F==-1&&p2.S==-1){
                    if(lp==-1) continue;
                    p2.F=a[i].F;
                    p2.S=a[lp].F;
                }
            }
        }
        trace(p1,p2);
        if((p2.F!=-1||p2.S!=-1)&&(p1.F!=-1||p1.S!=-1)){
            if(p1.F*p2.S > p2.F*p1.S){
                ans=mul(mul(ans,-p1.F,M1),inv(p1.S,M1),M1);
            }else{
                ans=mul(mul(ans,-p2.F,M1),inv(p2.S,M1),M1);
            }
        }else if(p1.F!=-1||p1.S!=-1){
            ans=mul(mul(ans,-p1.F,M1),inv(p1.S,M1),M1);
        }else if(p2.F!=-1||p2.S!=-1){
            trace(ans);
            ans=mul(mul(ans,-p2.F,M1),inv(p2.S,M1),M1);
        }
    }
    if(k%2 && pos==0){
        ans=1;
        reverse(all(a));
        for(ll i=0;i<k;i++) ans=mul(ans,a[i].F*a[i].S,M1);
    }
    if(ans<0) ans+=M1;
    d1(ans);
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<fixed<<setprecision(25);
    pre();
    ll t=1;
    // cin>>t;
    for(ll tt=1;tt<=t;tt++){
        // cout<<"Test Case #"<<tt<<" :\n";
        solve();
    }
    return 0;
}

Measured memory_bytes: 6364