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

P = []
M = []
Z = []
for i in range(N):
    if A[i]>0:
        P.append(A[i])
    elif A[i]<0:
        M.append(A[i])
    else:
        Z.append(A[i])

mod = 1000000007

if len(P)+len(M) < K:
    print(0)
elif len(P)==0:
    if K%2==1:
        if len(Z)>0:
            print(0)
        else:
            M.sort(reverse=True)
            ans = 1
            for i in range(K):
                ans*=abs(M[i])
                ans%=mod
            if ans==0:
                print(ans)
            else:
                print(mod-ans)
    else:
        M.sort()
        ans = 1
        for i in range(K):
            ans*=abs(M[i])
            ans%=mod
        print(ans)
else:
    B = [(abs(A[i]),A[i]) for i in range(N)]
    B.sort(reverse=True,key=lambda x:x[0])
    pc = 0
    lastpc = -1
    mc = 0
    lastmc = -1
    for i in range(K):
        if B[i][1]>0:
            pc += 1
            lastpc = i
        else:
            mc += 1
            lastmc = i
    if mc%2==0:
        ans = 1
        for i in range(K):
            ans *= B[i][0]
            ans %= mod
        print(ans)
    else:
        nextpc = -1
        nextmc = -1
        for i in range(K,N):
            if B[i][1]>0:
                if nextpc==-1:
                    nextpc=i
            elif B[i][1]<0:
                if nextmc==-1:
                    nextmc=i
        if nextmc==-1 and nextpc==-1:
            if len(Z)>0:
                print(0)
            else:
                ans = 1
                for i in range(K):
                    ans *= B[i][0]
                    ans %= mod
                if ans==0:
                    print(ans)
                else:
                    print(mod-ans)
        elif nextmc==-1:
            ans = 1
            for i in range(K):
                if i!=lastmc:
                    ans *= B[i][0]
                    ans %= mod
            ans *= B[nextpc][0]
            ans %= mod
            print(ans)
        elif nextpc==-1:
            ans = 1
            for i in range(K):
                if i!=lastpc:
                    ans *= B[i][0]
                    ans %= mod
            ans *= B[nextmc][0]
            ans %= mod
            print(ans)
        else:
            if lastpc==-1:
                ans = 1
                for i in range(K):
                    if i!=lastmc:
                        ans *= B[i][0]
                        ans %= mod
                ans *= B[nextpc][0]
                ans %= mod
                print(ans)
            elif lastmc==-1:
                ans = 1
                for i in range(K):
                    if i!=lastpc:
                        ans *= B[i][0]
                        ans %= mod
                ans *= B[nextmc][0]
                ans %= mod
                print(ans)
            elif B[nextpc][0]*B[lastpc][0] > B[nextmc][0]*B[lastmc][0]:
                ans = 1
                for i in range(K):
                    if i!=lastmc:
                        ans *= B[i][0]
                        ans %= mod
                ans *= B[nextpc][0]
                ans %= mod
                print(ans)
            else:
                ans = 1
                for i in range(K):
                    if i!=lastpc:
                        ans *= B[i][0]
                        ans %= mod
                ans *= B[nextmc][0]
                ans %= mod
                print(ans)




Measured memory_bytes: 126388