import java.util.*
import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

const val mod = 1000000007L

fun main() {
	abc000X()
}

fun abc000X() {
	val (n,k) = list()
	val a = list {toLong()}
	val b = a.groupBy {
		when {
			it>0->1
			it==0L->0
			else->-1
		}
	}
	val pos = (b[1]?.sorted() ?: emptyList()).toMutableList()
	val neg = (b[-1]?.sortedDescending() ?: emptyList()).toMutableList()

	if(k-min(neg.size/2*2,k/2*2)>pos.size) {
		a.sortedBy {abs(it)}
				.take(k)
				.reduce {o,p-> ((o+mod)%mod)*((p+mod)%mod)%mod}
				.let {println(it)}

	} else {
		var r = if(k%2==1) pos.removeAt(pos.lastIndex) else 1L
		for(i in 1..k/2) {
			val p = if(pos.size<2) 0 else pos[pos.lastIndex]*pos[pos.lastIndex-1]
			val q = if(neg.size<2) 0 else neg[neg.lastIndex]*neg[neg.lastIndex-1]
			if(p>q) {
				r = p%mod*r%mod
				pos.removeAt(pos.lastIndex)
				pos.removeAt(pos.lastIndex)
			} else {
				r = q%mod*r%mod
				neg.removeAt(neg.lastIndex)
				neg.removeAt(neg.lastIndex)
			}
		}
		println(r)
	}
}
