M=10**9+7

n,k,*a=list(map(int,open(y:=0).read().split()))

a.sort()

s=1

a=a[-k*(a[-1]<0<k%2):]

while k-y>1:

 if(t:=a[y]*a[y+1])>a[-1]*a[-2]:s=s*t%M;y+=2

 else:s=s*a.pop()%M;k-=1

if k-y:s*=a[-1]

print((s%M))
n,k,*a=list(map(int,open(i:=0).read().split()))

a.sort()

p=a.pop

s=b=~k%2or p()

for _ in k//2*'_':

 x=a[i]*a[i+1]

 if x*b>a[-1]*a[-2]*b:s*=x;i+=2

 else:s*=p()*p()

 s%=10**9+7

print(s)
M = 10**9 + 7
n, k, *a = list(map(int, open(y := 0).read().split()))
a.sort()
s = 1
a = a[-k * (a[-1] < 0 < k % 2) :]
while k - y > 1:
    if (t := a[y] * a[y + 1]) > a[-1] * a[-2]:
        s = s * t % M
        y += 2
    else:
        s = s * a.pop() % M
        k -= 1
if k - y:
    s *= a[-1]
print((s % M))

n, k, *a = list(map(int, open(i := 0).read().split()))
a.sort()
p = a.pop
s = b = ~k % 2 or p()
for _ in k // 2 * "_":
    x = a[i] * a[i + 1]
    if x * b > a[-1] * a[-2] * b:
        s *= x
        i += 2
    else:
        s *= p() * p()
    s %= 10**9 + 7
print(s)

-M = 10**9 + 7 -n, k, *a = list(map(int, open(y := 0).read().split())) +n, k, *a = list(map(int, open(i := 0).read().split())) -s = 1 -a = a[-k * (a[-1] < 0 < k % 2) :] -while k - y > 1: -    if (t := a[y] * a[y + 1]) > a[-1] * a[-2]: -        s = s * t % M -        y += 2 +p = a.pop +s = b = ~k % 2 or p() +for _ in k // 2 * "_": +    x = a[i] * a[i + 1] +    if x * b > a[-1] * a[-2] * b: +        s *= x +        i += 2 -        s = s * a.pop() % M -        k -= 1 -if k - y: -    s *= a[-1] -print((s % M)) +        s *= p() * p() +    s %= 10**9 + 7 +print(s)