

N, K = list(map(int, input().split()))

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

MOD = 10 ** 9 + 7



pos = sorted(v for v in X if v >= 0)

neg = sorted(-v for v in X if v < 0)



ok = False  # True: ans>=0, False: ans<0

if pos:

    if N == K:

        # Select all -> number of negatives must be even

        ok = len(neg) % 2 == 0

    else:

        ok = True

else:

    # All negative and even number is selected

    ok = K % 2 == 0



ans = 1

if ok:

    # ans >= 0

    if K % 2 == 1:

        ans = ans * pos.pop() % MOD



    # 答えは正になる→二つの数の積は必ず正になる．

    cand = []

    while len(pos) >= 2:

        x = pos.pop() * pos.pop()

        cand.append(x)



    while len(neg) >= 2:

        x = neg.pop() * neg.pop()

        cand.append(x)



    cand.sort(reverse=True)

    for i in range(K // 2):

        ans = ans * cand[i] % MOD

else:

    # ans <= 0

    cand = sorted(X, key=lambda x: abs(x))

    for i in range(K):

        ans = ans * cand[i] % MOD



print(ans)



N, K = list(map(int, input().split()))

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



MOD = 10 ** 9 + 7



if K % 2 == 1 and all(v < 0 for v in X):

    # Minimize abs

    X.sort(key=lambda x: -x)

    ans = 1

    for i in range(K):

        ans = ans * X[i] % MOD

    print(ans)

elif K == N:

    ans = 1

    for i in range(K):

        ans = ans * X[i] % MOD

    print(ans)

else:

    pos = sorted(v for v in X if v >= 0)

    neg = sorted(-v for v in X if v < 0)



    ans = 1

    if K % 2 == 1:

        ans *= pos.pop()



    cand = []

    while len(pos) >= 2:

        tmp = pos.pop() * pos.pop()

        cand.append(tmp)



    while len(neg) >= 2:

        tmp = neg.pop() * neg.pop()

        cand.append(tmp)



    cand.sort(reverse=True)

    for i in range(K // 2):

        ans = ans * cand[i] % MOD



    print(ans)

N, K = list(map(int, input().split()))
X = list(map(int, input().split()))
MOD = 10**9 + 7
pos = sorted(v for v in X if v >= 0)
neg = sorted(-v for v in X if v < 0)
ok = False  # True: ans>=0, False: ans<0
if pos:
    if N == K:
        # Select all -> number of negatives must be even
        ok = len(neg) % 2 == 0
    else:
        ok = True
else:
    # All negative and even number is selected
    ok = K % 2 == 0
ans = 1
if ok:
    # ans >= 0
    if K % 2 == 1:
        ans = ans * pos.pop() % MOD
    # 答えは正になる→二つの数の積は必ず正になる．
    cand = []
    while len(pos) >= 2:
        x = pos.pop() * pos.pop()
        cand.append(x)
    while len(neg) >= 2:
        x = neg.pop() * neg.pop()
        cand.append(x)
    cand.sort(reverse=True)
    for i in range(K // 2):
        ans = ans * cand[i] % MOD
else:
    # ans <= 0
    cand = sorted(X, key=lambda x: abs(x))
    for i in range(K):
        ans = ans * cand[i] % MOD
print(ans)

N, K = list(map(int, input().split()))
X = list(map(int, input().split()))
MOD = 10**9 + 7
if K % 2 == 1 and all(v < 0 for v in X):
    # Minimize abs
    X.sort(key=lambda x: -x)
    ans = 1
    for i in range(K):
        ans = ans * X[i] % MOD
    print(ans)
elif K == N:
    ans = 1
    for i in range(K):
        ans = ans * X[i] % MOD
    print(ans)
else:
    pos = sorted(v for v in X if v >= 0)
    neg = sorted(-v for v in X if v < 0)
    ans = 1
    if K % 2 == 1:
        ans *= pos.pop()
    cand = []
    while len(pos) >= 2:
        tmp = pos.pop() * pos.pop()
        cand.append(tmp)
    while len(neg) >= 2:
        tmp = neg.pop() * neg.pop()
        cand.append(tmp)
    cand.sort(reverse=True)
    for i in range(K // 2):
        ans = ans * cand[i] % MOD
    print(ans)

-pos = sorted(v for v in X if v >= 0) -neg = sorted(-v for v in X if v < 0) -ok = False  # True: ans>=0, False: ans<0 -if pos: -    if N == K: -        # Select all -> number of negatives must be even -        ok = len(neg) % 2 == 0 -    else: -        ok = True +if K % 2 == 1 and all(v < 0 for v in X): +    # Minimize abs +    X.sort(key=lambda x: -x) +    ans = 1 +    for i in range(K): +        ans = ans * X[i] % MOD +    print(ans) +elif K == N: +    ans = 1 +    for i in range(K): +        ans = ans * X[i] % MOD +    print(ans) -    # All negative and even number is selected -    ok = K % 2 == 0 -ans = 1 -if ok: -    # ans >= 0 +    pos = sorted(v for v in X if v >= 0) +    neg = sorted(-v for v in X if v < 0) +    ans = 1 -        ans = ans * pos.pop() % MOD -    # 答えは正になる→二つの数の積は必ず正になる． +        ans *= pos.pop() -        x = pos.pop() * pos.pop() -        cand.append(x) +        tmp = pos.pop() * pos.pop() +        cand.append(tmp) -        x = neg.pop() * neg.pop() -        cand.append(x) +        tmp = neg.pop() * neg.pop() +        cand.append(tmp) -else: -    # ans <= 0 -    cand = sorted(X, key=lambda x: abs(x)) -    for i in range(K): -        ans = ans * cand[i] % MOD -print(ans) +    print(ans)