#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <decimal/decimal>
using namespace std;
using namespace __gnu_pbds;

#define rep(i, s, t) for (int i = s; i < int(t); ++i)

#define sc	scanf
#define pr	printf
#define ff	first
#define ss	second
#define mp	make_pair
#define pb	push_back
#define eb	emplace_back
#define range(c)	c.begin(), c.end()
#define lowbit(x)	((x) & -(x))
#define pop_count	__builtin_popcount
#define pop_count_64	__builtin_popcountll
#define tail_count	__builtin_ctz
#define tail_count_64	__builtin_ctzll
#define lead_count	__builtin_clz
#define lead_count_64	__builtin_clzll

#define TEMP template<typename
#define CONST(type) constexpr type const

TEMP... Ts> struct is_con { static CONST(bool) value = false; };
TEMP... Ts> struct is_con<vector<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<list<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<deque<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<set<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<unordered_set<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<map<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<unordered_map<Ts...>> { static CONST(bool) value = true; };

TEMP T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2> const& p) { return os << "<" << p.ff << "," << p.ss << ">"; }
TEMP T> typename enable_if<is_con<T>::value, ostream>::type& operator<<(ostream& os, T const& c) {
	os << "{";
	bool first = true;
	for (auto const& x : c) {
		if (first) first = false;
		else os << ",";
		os << " " << x;
	}
	return os << " }";
}

TEMP T, typename... Ts> void dbg(T h, Ts... t) { cerr << " " << h; dbg<Ts...>(t...); }
template<> void dbg<int>(int x) { cerr << endl; }

#ifdef LOCAL
#define debug(...) cerr << "[ "#__VA_ARGS__" ] :", dbg(__VA_ARGS__, 0)
#else
#define debug(...) 0
#endif

TEMP T, typename U> using ordered_map = tree<T, U, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
TEMP T> using ordered_set = ordered_map<T, null_type>;

typedef long long i64;
typedef decimal::decimal128 i99;
typedef unsigned int u32;
typedef unsigned long long u64;
typedef float f32;
typedef double f64;
typedef long double f80;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<i64> vl;

TEMP T> T& minn(T& lhs, T const& rhs) { return lhs = min(lhs, rhs); }
TEMP T> T& maxx(T& lhs, T const& rhs) { return lhs = max(lhs, rhs); }

template<typename T> T inverse(T x, T p) {
	T a = 0, b = 1;
	while (x) {
		T t = p / x;
		p -= t * x; swap(x, p);
		a -= t * b; swap(a, b);
	}
	assert(p == 1);
	return a;
}

template<typename T> struct modular {
	static constexpr int mod() { return T::value; }
	template<typename U> static int norm(U const& x) { int y = -mod() <= x && x < mod() ? x : x % mod(); return y < 0 ? y + mod() : y; }

	int value;
	modular(): value() { }
	template<typename U> modular(U const& x): value(norm(x)) { }
	int operator()() const { return value; }
	template<typename U> explicit operator U() const { return static_cast<U>(value); }

	modular& operator+=(modular<T> const& other) { if ((value += other.value) >= mod()) value -= mod(); return *this; }
	modular& operator-=(modular<T> const& other) { if ((value -= other.value) < 0) value += mod(); return *this; }
	template<typename U> modular& operator+=(U const& other) { return *this += modular(other); }
	template<typename U> modular& operator-=(U const& other) { return *this -= modular(other); }
	modular& operator++() { return *this += 1; }
	modular& operator--() { return *this -= 1; }
	modular operator++(int) { modular ori(*this); *this += 1; return ori; }
	modular operator--(int) { modular ori(*this); *this -= 1; return ori; }
	modular operator-() const { return modular(-value); }
	modular operator~() const { return modular(inverse(value, mod())); }
	modular& operator*=(modular const& other) { value = norm(1LL * value * other.value); return *this; }
	modular& operator/=(modular const& other) { value = norm(1LL * value * inverse(other.value, mod())); return *this; }
	template<typename U> modular& operator*=(U const& other) { value = norm(1LL * value * other); return *this; }
	template<typename U> modular& operator/=(U const& other) { value = norm(1LL * value * inverse(other, mod())); return *this; }
	template<typename U> modular& operator^=(U const& other) {
		modular temp = other < 0 ? -*this : *this;
		*this = 1;
		other = abs(other);
		while (other) {
			if (other & 1) *this *= temp;
			temp *= temp;
			other >>= 1;
		}
		return *this;
	}
};

template<typename T> istream& operator>>(istream& is, modular<T>& x) { long long y; is >> y; x = y; return is; }
template<typename T> ostream& operator<<(ostream& os, modular<T> const& x) { return os << x(); }

template<typename T> bool operator==(modular<T> const& lhs, modular<T> const& rhs) { return lhs.value == rhs.value; }
template<typename T, typename U> bool operator==(modular<T> const& lhs, U const& rhs) { return lhs == modular<T>(rhs); }
template<typename T, typename U> bool operator==(U const& lhs, modular<T> const& rhs) { return modular<T>(lhs) == rhs; }

template<typename T> bool operator!=(modular<T> const& lhs, modular<T> const& rhs) { return !(lhs == rhs); }
template<typename T, typename U> bool operator!=(modular<T> const& lhs, U const& rhs) { return !(lhs == rhs); }
template<typename T, typename U> bool operator!=(U const& lhs, modular<T> const& rhs) { return !(lhs == rhs); }

template<typename T> modular<T> operator+(modular<T> const& lhs, modular<T> const& rhs) { return modular<T>(lhs) += rhs; }
template<typename T, typename U> modular<T> operator+(modular<T> const& lhs, U const& rhs) { return modular<T>(lhs) += rhs; }
template<typename T, typename U> modular<T> operator+(U const& lhs, modular<T> const& rhs) { return modular<T>(lhs) += rhs; }

template<typename T> modular<T> operator-(modular<T> const& lhs, modular<T> const& rhs) { return modular<T>(lhs) -= rhs; }
template<typename T, typename U> modular<T> operator-(modular<T> const& lhs, U const& rhs) { return modular<T>(lhs) -= rhs; }
template<typename T, typename U> modular<T> operator-(U const& lhs, modular<T> const& rhs) { return modular<T>(lhs) -= rhs; }

template<typename T> modular<T> operator*(modular<T> const& lhs, modular<T> const& rhs) { return modular<T>(lhs) *= rhs; }
template<typename T, typename U> modular<T> operator*(modular<T> const& lhs, U const& rhs) { return modular<T>(lhs) *= rhs; }
template<typename T, typename U> modular<T> operator*(U const& lhs, modular<T> const& rhs) { return modular<T>(lhs) *= rhs; }

template<typename T> modular<T> operator/(modular<T> const& lhs, modular<T> const& rhs) { return modular<T>(lhs) /= rhs; }
template<typename T, typename U> modular<T> operator/(modular<T> const& lhs, U const& rhs) { return modular<T>(lhs) /= rhs; }
template<typename T, typename U> modular<T> operator/(U const& lhs, modular<T> const& rhs) { return modular<T>(lhs) /= rhs; }

template<typename T, typename U> modular<T> operator^(modular<T> const& lhs, U const& rhs) { return modular<T>(lhs) ^= rhs; }

template<typename T> bool is_zero(modular<T> const& x) { return x.value == 0; }

struct var_mod { static int value; static void set(int mod) { value = mod; } };

using mod_t = modular<integral_constant<int, 1000000007>>;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, k;
	cin >> n >> k;
	vi a[2];
	rep(i, 0, n) {
		int x;
		cin >> x;
		a[x < 0].pb(abs(x));
	}
	rep(i, 0, 2) {
		sort(range(a[i]), greater<int>());
	}
	mod_t ans = 1;
	if (a[0].empty()) {
		if (k & 1) {
			ans = -1;
			reverse(range(a[1]));
		}
		rep(i, 0, k) {
			ans *= a[1][i];
		}
		cout << ans << endl;
		return 0;
	}
	if (n == k) {
		if (int(a[1].size()) & 1) {
			ans = -1;
		}
		rep(i, 0, 2) {
			for (const auto& x : a[i]) {
				ans *= x;
			}
		}
		cout << ans << endl;
		return 0;
	}
	int m = min(k, int(a[1].size())) >> 1 << 1;
	rep(i, 0, m) {
		ans *= a[1][i];
	}
	rep(i, 0, k - m) {
		ans *= a[0][i];
	}
	int x = m, y = k - m;
	while (x && y + 2 <= int(a[0].size())) {
		mod_t tmp = ans;
		tmp *= a[0][y];
		tmp *= a[0][y + 1];
		tmp /= a[1][x - 1];
		tmp /= a[1][x - 2];
		if (1LL * a[0][y] * a[0][y + 1] < 1LL * a[1][x - 1] * a[1][x - 2]) {
			break;
		}
		x -= 2;
		y += 2;
		ans = tmp;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4368