MOD = 10 ** 9 + 7

ans = 1



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

a = list(map(int, input().split()))



if n == k:

    for x in a:

        ans *= x

        ans %= MOD

    print((ans % MOD))

    exit()



pos = []

neg = []



for x in a:

    if x >= 0:

        pos.append(x)

    else:

        neg.append(x)



pos.sort(reverse=True)

neg.sort()



if len(pos) == 0 and k % 2:

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

        ans *= neg[-i]

        ans %= MOD

    print((ans % MOD))

    exit()



pi = 0

ni = 0

if k % 2:

    ans *= pos[pi]

    pi += 1

    k -= 1



while k > 0:

    if pi < len(pos) - 1:

        sp = pos[pi] * pos[pi + 1]

    else:

        sp = 0

    

    if ni < len(neg) - 1:

        sn = neg[ni] * neg[ni + 1]

    else:

        sn = 0

    

    if sp > sn:

        ans *= sp

        pi += 2

    else:

        ans *= sn

        ni += 2

    

    ans %= MOD

    k -= 2



print((ans % MOD))

MOD = 10 ** 9 + 7

ans = 1



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

a = list(map(int, input().split()))



if n == k:

    for x in a:

        ans *= x

        ans %= MOD

    print((ans % MOD))

    exit()



pos = []

neg = []



for x in a:

    if x >= 0:

        pos.append(x)

    else:

        neg.append(x)



pos.sort(reverse=True)

neg.sort()



if len(pos) == 0 and k % 2:

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

        ans *= neg[-i]

        ans %= MOD

    print((ans % MOD))

    exit()



if k % 2:

    ans *= pos.pop(0)

    k -= 1





l = []



for i in range(1, len(pos), 2):

    l.append(pos[i] * pos[i - 1])



for i in range(1, len(neg), 2):

    l.append(neg[i] * neg[i - 1])



l.sort(reverse=True)



for i in range(k // 2):

    ans *= l[i]

    ans %= MOD



print((ans % MOD))

MOD = 10**9 + 7
ans = 1
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
if n == k:
    for x in a:
        ans *= x
        ans %= MOD
    print((ans % MOD))
    exit()
pos = []
neg = []
for x in a:
    if x >= 0:
        pos.append(x)
    else:
        neg.append(x)
pos.sort(reverse=True)
neg.sort()
if len(pos) == 0 and k % 2:
    for i in range(1, k + 1):
        ans *= neg[-i]
        ans %= MOD
    print((ans % MOD))
    exit()
pi = 0
ni = 0
if k % 2:
    ans *= pos[pi]
    pi += 1
    k -= 1
while k > 0:
    if pi < len(pos) - 1:
        sp = pos[pi] * pos[pi + 1]
    else:
        sp = 0
    if ni < len(neg) - 1:
        sn = neg[ni] * neg[ni + 1]
    else:
        sn = 0
    if sp > sn:
        ans *= sp
        pi += 2
    else:
        ans *= sn
        ni += 2
    ans %= MOD
    k -= 2
print((ans % MOD))

MOD = 10**9 + 7
ans = 1
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
if n == k:
    for x in a:
        ans *= x
        ans %= MOD
    print((ans % MOD))
    exit()
pos = []
neg = []
for x in a:
    if x >= 0:
        pos.append(x)
    else:
        neg.append(x)
pos.sort(reverse=True)
neg.sort()
if len(pos) == 0 and k % 2:
    for i in range(1, k + 1):
        ans *= neg[-i]
        ans %= MOD
    print((ans % MOD))
    exit()
if k % 2:
    ans *= pos.pop(0)
    k -= 1
l = []
for i in range(1, len(pos), 2):
    l.append(pos[i] * pos[i - 1])
for i in range(1, len(neg), 2):
    l.append(neg[i] * neg[i - 1])
l.sort(reverse=True)
for i in range(k // 2):
    ans *= l[i]
    ans %= MOD
print((ans % MOD))

-pi = 0 -ni = 0 -    ans *= pos[pi] -    pi += 1 +    ans *= pos.pop(0) -while k > 0: -    if pi < len(pos) - 1: -        sp = pos[pi] * pos[pi + 1] -    else: -        sp = 0 -    if ni < len(neg) - 1: -        sn = neg[ni] * neg[ni + 1] -    else: -        sn = 0 -    if sp > sn: -        ans *= sp -        pi += 2 -    else: -        ans *= sn -        ni += 2 +l = [] +for i in range(1, len(pos), 2): +    l.append(pos[i] * pos[i - 1]) +for i in range(1, len(neg), 2): +    l.append(neg[i] * neg[i - 1]) +l.sort(reverse=True) +for i in range(k // 2): +    ans *= l[i] -    k -= 2