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

a.sort()

p=a.pop

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

while k>1:

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

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

 s%=10**9+7;k-=2

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

a.sort()

p=a.pop

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

i=0

while k>1:

 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;k-=2

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

n, k, *a = list(map(int, open(0).read().split()))
a.sort()
p = a.pop
s = b = ~k % 2 or p()
i = 0
while k > 1:
    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
    k -= 2
print(s)

-n, k, *a = list(map(int, open(i := 0).read().split())) +n, k, *a = list(map(int, open(0).read().split())) +i = 0 -    if (x := a[i] * a[i + 1]) * b > a[-1] * a[-2] * b: +    x = a[i] * a[i + 1] +    if x * b > a[-1] * a[-2] * b: