@staticmethod
def e():
    MOD = ((10 ** 9) + 7)
    (n, k, *a) = map(int, sys.stdin.read().split())
    minus = [x for x in a if (x < 0)]
    plus = [x for x in a if (x > 0)]
    if ((len(plus) + ((len(minus) // 2) * 2)) >= k):
        (*minus,) = map(abs, minus)
        minus.sort(reverse=True)
        plus.sort(reverse=True)
        cand = []
        if (len(minus) & 1):
            minus = minus[:(- 1)]
        for i in range(0, (len(minus) - 1), 2):
            cand.append(((minus[i] * minus[(i + 1)]) % MOD))
        if (k & 1):
            res = plus[0]
            plus = plus[1:]
        else:
            res = 1
        if (len(plus) & 1):
            plus = plus[:(- 1)]
        for i in range(0, (len(plus) - 1), 2):
            cand.append(((plus[i] * plus[(i + 1)]) % MOD))
        cand.sort(reverse=True)
        for x in cand[:(k // 2)]:
            res *= x
            res %= MOD
        print(res)
    elif (0 in a):
        print(0)
    else:
        cand = sorted(map(abs, a))
        res = 1
        for i in range(k):
            res *= cand[i]
            res %= MOD
        res = (MOD - res)
        print(res)
        pass
@staticmethod
def e():
    MOD = ((10 ** 9) + 7)
    (n, k, *a) = map(int, sys.stdin.read().split())
    minus = [x for x in a if (x < 0)]
    plus = [x for x in a if (x > 0)]
    if ((len(plus) + ((len(minus) // 2) * 2)) >= k):
        (*minus,) = map(abs, minus)
        minus.sort(reverse=True)
        plus.sort(reverse=True)
        cand = []
        if (len(minus) & 1):
            minus = minus[:(- 1)]
        for i in range(0, (len(minus) - 1), 2):
            cand.append(((minus[i] * minus[(i + 1)]) % MOD))
        if (k & 1):
            res = plus[0]
            plus = plus[1:]
        else:
            res = 1
        if (len(plus) & 1):
            plus = plus[:(- 1)]
        for i in range(0, (len(plus) - 1), 2):
            cand.append(((plus[i] * plus[(i + 1)]) % MOD))
        cand.sort(reverse=True)
        for x in cand[:(k // 2)]:
            res *= x
            res %= MOD
        print(res)
    elif (0 in a):
        print(0)
    else:
        cand = sorted(map(abs, a))
        res = 1
        for i in range(k):
            res *= cand[i]
            res %= MOD
        res = (MOD - res)
        print(res)
        pass