from heapq import heappop, heappush

mod = 10**9+7

n, k = list(map(int, input().split()))

a = [int(x) for x in input().split()]





def sgn(x):

    if x >= 0:

        return 0

    elif x < 0:

        return 1





pl = []

mn = []



for x in a:

    if x >= 0:

        pl.append(x)

    elif x < 0:

        mn.append(-x)



pl = sorted(pl, reverse=True)

mn = sorted(mn, reverse=True)





b = [(abs(a[i]), sgn(a[i])) for i in range(n)]

b = sorted(b, reverse=True)



c = [0, 0]

for i in range(k):

    c[b[i][1]] += 1





def solve(c):

    ans = 1

    for i in range(c[0]):

        ans *= pl[i]

        ans %= mod

    for i in range(c[1]):

        ans *= mn[i]

        ans %= mod

    if c[1] % 2:

        ans = (-ans) % mod

    return ans





if c[1] % 2 == 0:

    print((solve(c)))

    exit()



if len(mn) == n and k % 2:

    tmp = 1

    for i in range(k):

        tmp *= mn[-i-1]

        tmp %= mod

    ans = -tmp

    print((ans % mod))

    exit()



ans = 0



chk1 = False

chk2 = False



if c[0] <= len(pl) - 1:

    chk1 = True



if 0 < c[0] and c[1] <= len(mn)-1:

    chk2 = True



if chk1 and chk2:

    tmp1 = pl[c[0]]*pl[c[0]-1]

    tmp2 = mn[c[1]]*mn[c[1]-1]

    if tmp1 > tmp2:

        c[0] += 1

        c[1] -= 1

        print((solve(c)))

    else:

        c[0] -= 1

        c[1] += 1

        print((solve(c)))

elif chk1:

    c[0] += 1

    c[1] -= 1

    print((solve(c)))

elif chk2:

    c[0] -= 1

    c[1] += 1

    print((solve(c)))

else:

    print((solve(c)))

mod = 10**9+7

n, k = list(map(int, input().split()))

a = [int(x) for x in input().split()]



pl = []

mn = []

zr = []



tmp = 1

cnt = 0



for x in a:

    if x > 0:

        pl.append(x)

    elif x < 0:

        mn.append(-x)

    else:

        zr.append(x)



pl = sorted(pl, reverse=True)

mn = sorted(mn, reverse=True)



ans = 0



if n == k:

    ans = 1

    for i in range(n):

        ans *= a[i]

        ans %= mod

    print(ans)

    exit()



if len(mn) >= k and k % 2:

    tmp = 1

    for i in range(1, k+1):

        tmp *= mn[-i]

        tmp %= mod

    ans = -tmp



if len(zr) > 0:

    ans = max(0, ans)



pl_cum = [1]

for i, x in enumerate(pl):

    pl_cum.append(pl_cum[-1]*x % mod)



mn_cum = [1]

for i, x in enumerate(mn):

    mn_cum.append(mn_cum[-1]*x % mod)





for p in range(0, k+1, 2):

    if len(mn) < p:

        break

    first = False

    if len(pl) >= k-p:

        first = True

        pl_ind = k-p

        mn_ind = p

        break



if not first:

    print((ans % mod))

    exit()



while pl_ind-2 > -1 and mn_ind+1 < len(mn):

    if pl[pl_ind-1]*pl[pl_ind-2] <= mn[mn_ind]*mn[mn_ind+1]:

        pl_ind -= 2

        mn_ind += 2

    else:

        break



if pl_ind < 0:

    ans = mn_cum[mn_ind]

else:

    ans = pl_cum[pl_ind]*mn_cum[mn_ind]



print((ans % mod))

from heapq import heappop, heappush

mod = 10**9 + 7
n, k = list(map(int, input().split()))
a = [int(x) for x in input().split()]


def sgn(x):
    if x >= 0:
        return 0
    elif x < 0:
        return 1


pl = []
mn = []
for x in a:
    if x >= 0:
        pl.append(x)
    elif x < 0:
        mn.append(-x)
pl = sorted(pl, reverse=True)
mn = sorted(mn, reverse=True)
b = [(abs(a[i]), sgn(a[i])) for i in range(n)]
b = sorted(b, reverse=True)
c = [0, 0]
for i in range(k):
    c[b[i][1]] += 1


def solve(c):
    ans = 1
    for i in range(c[0]):
        ans *= pl[i]
        ans %= mod
    for i in range(c[1]):
        ans *= mn[i]
        ans %= mod
    if c[1] % 2:
        ans = (-ans) % mod
    return ans


if c[1] % 2 == 0:
    print((solve(c)))
    exit()
if len(mn) == n and k % 2:
    tmp = 1
    for i in range(k):
        tmp *= mn[-i - 1]
        tmp %= mod
    ans = -tmp
    print((ans % mod))
    exit()
ans = 0
chk1 = False
chk2 = False
if c[0] <= len(pl) - 1:
    chk1 = True
if 0 < c[0] and c[1] <= len(mn) - 1:
    chk2 = True
if chk1 and chk2:
    tmp1 = pl[c[0]] * pl[c[0] - 1]
    tmp2 = mn[c[1]] * mn[c[1] - 1]
    if tmp1 > tmp2:
        c[0] += 1
        c[1] -= 1
        print((solve(c)))
    else:
        c[0] -= 1
        c[1] += 1
        print((solve(c)))
elif chk1:
    c[0] += 1
    c[1] -= 1
    print((solve(c)))
elif chk2:
    c[0] -= 1
    c[1] += 1
    print((solve(c)))
else:
    print((solve(c)))

mod = 10**9 + 7
n, k = list(map(int, input().split()))
a = [int(x) for x in input().split()]
pl = []
mn = []
zr = []
tmp = 1
cnt = 0
for x in a:
    if x > 0:
        pl.append(x)
    elif x < 0:
        mn.append(-x)
    else:
        zr.append(x)
pl = sorted(pl, reverse=True)
mn = sorted(mn, reverse=True)
ans = 0
if n == k:
    ans = 1
    for i in range(n):
        ans *= a[i]
        ans %= mod
    print(ans)
    exit()
if len(mn) >= k and k % 2:
    tmp = 1
    for i in range(1, k + 1):
        tmp *= mn[-i]
        tmp %= mod
    ans = -tmp
if len(zr) > 0:
    ans = max(0, ans)
pl_cum = [1]
for i, x in enumerate(pl):
    pl_cum.append(pl_cum[-1] * x % mod)
mn_cum = [1]
for i, x in enumerate(mn):
    mn_cum.append(mn_cum[-1] * x % mod)
for p in range(0, k + 1, 2):
    if len(mn) < p:
        break
    first = False
    if len(pl) >= k - p:
        first = True
        pl_ind = k - p
        mn_ind = p
        break
if not first:
    print((ans % mod))
    exit()
while pl_ind - 2 > -1 and mn_ind + 1 < len(mn):
    if pl[pl_ind - 1] * pl[pl_ind - 2] <= mn[mn_ind] * mn[mn_ind + 1]:
        pl_ind -= 2
        mn_ind += 2
    else:
        break
if pl_ind < 0:
    ans = mn_cum[mn_ind]
else:
    ans = pl_cum[pl_ind] * mn_cum[mn_ind]
print((ans % mod))

-from heapq import heappop, heappush - - - -def sgn(x): -    if x >= 0: -        return 0 -    elif x < 0: -        return 1 - - +zr = [] +tmp = 1 +cnt = 0 -    if x >= 0: +    if x > 0: +    else: +        zr.append(x) -b = [(abs(a[i]), sgn(a[i])) for i in range(n)] -b = sorted(b, reverse=True) -c = [0, 0] -for i in range(k): -    c[b[i][1]] += 1 - - -def solve(c): +ans = 0 +if n == k: -    for i in range(c[0]): -        ans *= pl[i] +    for i in range(n): +        ans *= a[i] -    for i in range(c[1]): -        ans *= mn[i] -        ans %= mod -    if c[1] % 2: -        ans = (-ans) % mod -    return ans - - -if c[1] % 2 == 0: -    print((solve(c))) +    print(ans) -if len(mn) == n and k % 2: +if len(mn) >= k and k % 2: -    for i in range(k): -        tmp *= mn[-i - 1] +    for i in range(1, k + 1): +        tmp *= mn[-i] +if len(zr) > 0: +    ans = max(0, ans) +pl_cum = [1] +for i, x in enumerate(pl): +    pl_cum.append(pl_cum[-1] * x % mod) +mn_cum = [1] +for i, x in enumerate(mn): +    mn_cum.append(mn_cum[-1] * x % mod) +for p in range(0, k + 1, 2): +    if len(mn) < p: +        break +    first = False +    if len(pl) >= k - p: +        first = True +        pl_ind = k - p +        mn_ind = p +        break +if not first: -ans = 0 -chk1 = False -chk2 = False -if c[0] <= len(pl) - 1: -    chk1 = True -if 0 < c[0] and c[1] <= len(mn) - 1: -    chk2 = True -if chk1 and chk2: -    tmp1 = pl[c[0]] * pl[c[0] - 1] -    tmp2 = mn[c[1]] * mn[c[1] - 1] -    if tmp1 > tmp2: -        c[0] += 1 -        c[1] -= 1 -        print((solve(c))) +while pl_ind - 2 > -1 and mn_ind + 1 < len(mn): +    if pl[pl_ind - 1] * pl[pl_ind - 2] <= mn[mn_ind] * mn[mn_ind + 1]: +        pl_ind -= 2 +        mn_ind += 2 -        c[0] -= 1 -        c[1] += 1 -        print((solve(c))) -elif chk1: -    c[0] += 1 -    c[1] -= 1 -    print((solve(c))) -elif chk2: -    c[0] -= 1 -    c[1] += 1 -    print((solve(c))) +        break +if pl_ind < 0: +    ans = mn_cum[mn_ind] -    print((solve(c))) +    ans = pl_cum[pl_ind] * mn_cum[mn_ind] +print((ans % mod))