/*
मनस्वी म्रियते कामं कार्पण्यं न तु गच्छति ।
अपि निर्वाणमायाति नानलो याति शीतताम् ॥
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define p2d(v) for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v) for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v) for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
#define test3(x,y,z) cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define test4(w,x,y,z) cout << #w " = " << w << " " << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

    ll n,k;
    cin>>n>>k;
        
    vl v(n);

    vl pos,neg;

    priority_queue<ppl> pq;

    forn(i,0,n)
    {
        cin>>v[i];
        if(v[i] < 0) neg.pb(-v[i]),pq.push({-v[i],-1});
        else pos.pb(v[i]),pq.push({v[i],1});
    }
    
    vl vp;

    ll total = 0;
    ll ele1 = 1e18,ele2 = 1e18;
    forn(i,0,k)
    {
        ppl p = pq.top();
        pq.pop();
        if(p.ss == -1)
        {
            total++;
            ele1 = p.ff;
        } 
        else
        {
            ele2 = p.ff;
        }
        vp.pb(p.ff);
    }

    // p1d(vp)

    // test3(total,ele1,ele2)

    if(total&1)
    {
        bool val = 0;
        ll a = -1e18,b = -1e18;
        while(!pq.empty())
        {
            ppl p = pq.top();
            pq.pop();
            if(p.ss == 1)
            {
                if(a == -1e18) a = p.ff;
                // val = 1;
                // ele2 = p.ff;
                // break;
            }
            else if(p.ss == -1)
            {
                if(ele2 != 1e18 && b == -1e18) b = p.ff;
            }
        }   

        if(a != -1e18 && b != -1e18)
        {
            if((a*ele2) > (b*ele1))
            {
                for(int i = 0; i < vp.size(); i++)
                {
                    if(vp[i] == ele1)
                    {
                        vp[i] = a;
                        break;
                    }
                }                   
            }
            else
            {
                for(int i = 0; i < vp.size(); i++)
                {
                    if(vp[i] == ele2)
                    {
                        vp[i] = b;
                        break;
                    }
                }                                   
            }
        }
        else if(a != -1e18)
        {
            for(int i = 0; i < vp.size(); i++)
            {
                if(vp[i] == ele1)
                {
                    vp[i] = a;
                    break;
                }
            }                
        }
        else if(b != -1e18)
        {
            for(int i = 0; i < vp.size(); i++)
            {
                if(vp[i] == ele2)
                {
                    vp[i] = b;
                    break;
                }
            }                
        }
        else
        {

            vl v1;
            if(neg.size())
            {            
                forv(i,neg)
                {
                    v1.pb(i);
                }
            }
            if(pos.size())
            {            
                forv(i,pos)
                {
                    v1.pb(i);
                }
            }
            sort(all(v1));
            ll product = 1;
            forn(i,0,k)
            {
                product = (product*v1[i])%mod;
            }
            // test1(product)
            cout<<(mod-product)%mod;
            return 0;
        }
    }

    // test2(ele2,ele1)

    // p1d(vp)

    ll product = 1;
    forv(i,vp)
    {
        product = (product*i)%mod;
    }

    cout<<(mod+product)%mod;

    return 0;
}

Measured memory_bytes: 14736