#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    int k, n;
    cin >> n >> k;

    ll a[n];
    vector<pair<ll, int> > p;
    for(int i= 0; i < n; i++){
        cin >> a[i];
        if(a[i] == 0){
            p.push_back(make_pair(a[i], 0));
        }else if(a[i] > 0){
            p.push_back(make_pair(a[i], 1));
        }else{
            p.push_back(make_pair(-a[i], -1));
        }
    }

    sort(p.begin(), p.end(), greater<pair<ll, int> >());
    int cou = 0;
    for(int i = 0; i < k; i++){
        if(p[i].second == -1){
            cou++;
        }
    }

    ll che = 10e8 + 7;
    ll now = 1;

    if(cou % 2 == 0){
        for(int i = 0; i < k; i++){
            now *= p[i].first;
            now %= che;
        }
    }else{
        int pu = -1;
        int mi = -1;
        for(int i = k - 1; i >= 0; i--){
            if(p[i].second == -1 && mi == -1){
                mi = i;
            }

            if(p[i].second == 1 && pu == -1){
                pu = i;
            }

            if(mi != -1 && pu != -1){
                break;
            }
        }

        if(pu == -1){
            for(int i = k; i < n; i++){
                if(p[i].second == 1){
                    pu = i;
                    break;
                }
            }

            if(pu == -1){
                if(p[n - 1].second != 0){
                    for(int i = 0; i < k; i++){
                        now *= (0 - p[n - i - 1].first);
                        now %= che;
                        now += che;
                        now %= che;
                    }
                }else{
                    now = 0;
                }
            }else{
                for(int i = 0; i < k - 1; i++){
                    now *= p[i].first;
                    now %= che;
                }
                now *= p[pu].first;
                now %= che;
            }
        }else{
            int pp = -1;
            int mm = -1;
            for(int i = k; i < n; i++){
                if(p[i].second == -1 && mm == -1){
                    mm = i;
                }

                if(p[i].second == 1 && pp == -1){
                    pp = i;
                }

                if(mm != -1 && pp != -1){
                    break;
                }
            }

            for(int i = 0; i < k; i++){
                if(i != mi && i != pu){
                    now *= p[i].first;
                    now %= che;
                }
            }

            if(mm != -1 && pp != -1){
                ll t = 0;
                if(p[pp].first * p[pu].first > p[mm].first * p[mi].first){
                    t = 1;
                }else{
                    t = -1;
                }

                if(t == 1){
                    now *= p[pp].first;
                    now %= che;
                    now *= p[pu].first;
                    now %= che;
                }else{
                    now *= p[mm].first;
                    now %= che;
                    now *= p[mi].first;
                    now %= che;
                }
            }else if(pp != -1){
                now *= p[pp].first;
                now %= che;
                now *= p[pu].first;
                now %= che;
            }else if(mm != -1){
                now *= p[mm].first;
                now %= che;
                now *= p[mi].first;
                now %= che;
            }else{
                if(k != n){
                    now = 0;
                }else{
                    now = 1;
                    for(int i = 0; i < k; i++){
                        if(p[i].second == -1){
                            now *= (0 - p[i].first);
                            now %= che;
                            now += che;
                            now %= che;
                        }else{
                            now *= p[i].first;
                            now %= che;
                        }
                    }
                }
            }
        }
    }

    cout << now << endl;

}

Measured memory_bytes: 8444