#!/usr/bin/env python3
import sys
from collections import deque
MOD = 1000000007  # type: int


def solve(N: int, K: int, A: "List[int]"):
    mp = sum([int(a<=0) for a in A])
    pl = True
    if N == K:
        if mp%2 == 0:     pl = True
        else:     pl = False
    if mp == N:
        if K%2 == 0: pl = True
        else: pl = False

    absA = sorted(A, key=abs)
    sA = deque(absA)
    ans = 1
    k = 1
    if pl:
        for i in range(K):
            t = sA.pop()
            ans*= t
            k *= int(t>0)*2-1
            ans%= MOD

        if k<0:
            pre=absA[i]
            prei = i
            while((i!=N) and ((absA[i] * pre)>0) ): i+=1
            if i==N:
                pre = avsA[prei+1]
                i = prei
                while((absA[i]*pre)>0 ): i-=1
            
                ans//= absA[i]
                ans*= pre
            else:
                ans //= pre
                ans *= ansA[i]

        print(ans%MOD)

    else:
        for i in range(K):
            ans*= sA.popleft()
            ans%= MOD
        print(ans%MOD)


    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()
