MOD=10**9+7

N,K=[int(s) for s in input().split()]

ls=[int(s) for s in input().split()]

ans=set()

ls=sorted(ls, key=lambda x: -abs(x))

mul=1

sign=0

zeroflag=0

flag=[0 for _ in range(N)]

for i in range(K):

  flag[i]=1

  if ls[i]<0:

    sign=(sign+1)%2

if sign==1:

  if 0 in ls:

    zeroflag=1

  a=[0,0,0,0]

  b=[0,0,0,0]

  for j in range(K,N):

    if ls[j]>0:

      for k in range(K):

        if ls[K-1-k]<0:

          a[0]=ls[j]

          b[0]=j

          a[1]=ls[K-1-k]

          b[1]=K-1-k

          break

      break

  for j in range(K,N):

    if ls[j]<0:

      for k in range(K):

        if ls[K-1-k]>0:

          a[2]=ls[j]

          b[2]=j

          a[3]=ls[K-1-k]

          b[3]=K-1-k

          break

      break

  if a==[0,0,0,0]:

    flag.reverse()

  elif b[0]==0 and b[1]==0:

    flag[b[2]]=1

    flag[b[3]]=0

  elif b[2]==0 and b[3]==0:

    flag[b[0]]=1

    flag[b[1]]=0

  elif abs(a[0]*a[3])>abs(a[1]*a[2]):

    flag[b[0]]=1

    flag[b[1]]=0

  else:

    flag[b[2]]=1

    flag[b[3]]=0

if sign==1 and a==[0,0,0,0] and zeroflag==1:

  print((0))

else:

  mul=1

  for i in range(N):

    if flag[i]==1:

      mul=mul*ls[i]%MOD

  print(mul)

MOD=10**9+7

N,K=[int(s) for s in input().split()]

ls=[int(s) for s in input().split()]

ls=sorted(ls, key=lambda x: -abs(x))



#かける数をフラグで管理

flag=[0 for _ in range(N)]



sign=0

for i in range(K):

  flag[i]=1

  if ls[i]<0:

    sign=(sign+1)%2



if sign==1: #絶対値が大きい順にかけた数は負か？

  #フラグのない負の数を、フラグのある正の数と取り換え可能か？

  swap_neg_to_pos=[]

  for i in range(K,N):

    if ls[i]<0:

      for j in range(K):

        if ls[K-1-j]>0:

          swap_neg_to_pos=[i,K-1-j,ls[K-1-j],-ls[i]]

          break

      break

  #フラグのない正の数を、フラグのある負の数と取り換え可能か？

  swap_pos_to_neg=[]

  for i in range(K,N):

    if ls[i]>0:

      for j in range(K):

        if ls[K-1-j]<0:

          swap_pos_to_neg=[i,K-1-j,-ls[K-1-j],ls[i]]

          break

      break



  #フラグを修正        

  if swap_neg_to_pos!=[] and swap_pos_to_neg!=[]: #どちらも取り換え可能なとき

    #負の数にフラグを与えたほうがロスが少ないとき

    if swap_neg_to_pos[2]*swap_pos_to_neg[3]<swap_pos_to_neg[2]*swap_neg_to_pos[3]: 

      flag[swap_neg_to_pos[0]]=1

      flag[swap_neg_to_pos[1]]=0

    else: #正の数にフラグを与えたほうがロスが少ないとき

      flag[swap_pos_to_neg[0]]=1

      flag[swap_pos_to_neg[1]]=0

  elif swap_neg_to_pos==[] and swap_pos_to_neg==[]: #どちらも取り換え不可能なとき 

    flag.reverse()

  elif swap_pos_to_neg!=[]: #正の数にフラグを与えることのみ可能なとき

    flag[swap_pos_to_neg[0]]=1

    flag[swap_pos_to_neg[1]]=0

  else:                     #負の数にフラグを与えることのみ可能なとき

    flag[swap_neg_to_pos[0]]=1

    flag[swap_neg_to_pos[1]]=0



ans=1

for i in range(N):

  if flag[i]==1:

    ans=(ans*ls[i])%MOD

print(ans)

MOD = 10**9 + 7
N, K = [int(s) for s in input().split()]
ls = [int(s) for s in input().split()]
ans = set()
ls = sorted(ls, key=lambda x: -abs(x))
mul = 1
sign = 0
zeroflag = 0
flag = [0 for _ in range(N)]
for i in range(K):
    flag[i] = 1
    if ls[i] < 0:
        sign = (sign + 1) % 2
if sign == 1:
    if 0 in ls:
        zeroflag = 1
    a = [0, 0, 0, 0]
    b = [0, 0, 0, 0]
    for j in range(K, N):
        if ls[j] > 0:
            for k in range(K):
                if ls[K - 1 - k] < 0:
                    a[0] = ls[j]
                    b[0] = j
                    a[1] = ls[K - 1 - k]
                    b[1] = K - 1 - k
                    break
            break
    for j in range(K, N):
        if ls[j] < 0:
            for k in range(K):
                if ls[K - 1 - k] > 0:
                    a[2] = ls[j]
                    b[2] = j
                    a[3] = ls[K - 1 - k]
                    b[3] = K - 1 - k
                    break
            break
    if a == [0, 0, 0, 0]:
        flag.reverse()
    elif b[0] == 0 and b[1] == 0:
        flag[b[2]] = 1
        flag[b[3]] = 0
    elif b[2] == 0 and b[3] == 0:
        flag[b[0]] = 1
        flag[b[1]] = 0
    elif abs(a[0] * a[3]) > abs(a[1] * a[2]):
        flag[b[0]] = 1
        flag[b[1]] = 0
    else:
        flag[b[2]] = 1
        flag[b[3]] = 0
if sign == 1 and a == [0, 0, 0, 0] and zeroflag == 1:
    print((0))
else:
    mul = 1
    for i in range(N):
        if flag[i] == 1:
            mul = mul * ls[i] % MOD
    print(mul)

MOD = 10**9 + 7
N, K = [int(s) for s in input().split()]
ls = [int(s) for s in input().split()]
ls = sorted(ls, key=lambda x: -abs(x))
# かける数をフラグで管理
flag = [0 for _ in range(N)]
sign = 0
for i in range(K):
    flag[i] = 1
    if ls[i] < 0:
        sign = (sign + 1) % 2
if sign == 1:  # 絶対値が大きい順にかけた数は負か？
    # フラグのない負の数を、フラグのある正の数と取り換え可能か？
    swap_neg_to_pos = []
    for i in range(K, N):
        if ls[i] < 0:
            for j in range(K):
                if ls[K - 1 - j] > 0:
                    swap_neg_to_pos = [i, K - 1 - j, ls[K - 1 - j], -ls[i]]
                    break
            break
    # フラグのない正の数を、フラグのある負の数と取り換え可能か？
    swap_pos_to_neg = []
    for i in range(K, N):
        if ls[i] > 0:
            for j in range(K):
                if ls[K - 1 - j] < 0:
                    swap_pos_to_neg = [i, K - 1 - j, -ls[K - 1 - j], ls[i]]
                    break
            break
    # フラグを修正
    if swap_neg_to_pos != [] and swap_pos_to_neg != []:  # どちらも取り換え可能なとき
        # 負の数にフラグを与えたほうがロスが少ないとき
        if (
            swap_neg_to_pos[2] * swap_pos_to_neg[3]
            < swap_pos_to_neg[2] * swap_neg_to_pos[3]
        ):
            flag[swap_neg_to_pos[0]] = 1
            flag[swap_neg_to_pos[1]] = 0
        else:  # 正の数にフラグを与えたほうがロスが少ないとき
            flag[swap_pos_to_neg[0]] = 1
            flag[swap_pos_to_neg[1]] = 0
    elif swap_neg_to_pos == [] and swap_pos_to_neg == []:  # どちらも取り換え不可能なとき
        flag.reverse()
    elif swap_pos_to_neg != []:  # 正の数にフラグを与えることのみ可能なとき
        flag[swap_pos_to_neg[0]] = 1
        flag[swap_pos_to_neg[1]] = 0
    else:  # 負の数にフラグを与えることのみ可能なとき
        flag[swap_neg_to_pos[0]] = 1
        flag[swap_neg_to_pos[1]] = 0
ans = 1
for i in range(N):
    if flag[i] == 1:
        ans = (ans * ls[i]) % MOD
print(ans)

-ans = set() -mul = 1 +# かける数をフラグで管理 +flag = [0 for _ in range(N)] -zeroflag = 0 -flag = [0 for _ in range(N)] -if sign == 1: -    if 0 in ls: -        zeroflag = 1 -    a = [0, 0, 0, 0] -    b = [0, 0, 0, 0] -    for j in range(K, N): -        if ls[j] > 0: -            for k in range(K): -                if ls[K - 1 - k] < 0: -                    a[0] = ls[j] -                    b[0] = j -                    a[1] = ls[K - 1 - k] -                    b[1] = K - 1 - k +if sign == 1:  # 絶対値が大きい順にかけた数は負か？ +    # フラグのない負の数を、フラグのある正の数と取り換え可能か？ +    swap_neg_to_pos = [] +    for i in range(K, N): +        if ls[i] < 0: +            for j in range(K): +                if ls[K - 1 - j] > 0: +                    swap_neg_to_pos = [i, K - 1 - j, ls[K - 1 - j], -ls[i]] -    for j in range(K, N): -        if ls[j] < 0: -            for k in range(K): -                if ls[K - 1 - k] > 0: -                    a[2] = ls[j] -                    b[2] = j -                    a[3] = ls[K - 1 - k] -                    b[3] = K - 1 - k +    # フラグのない正の数を、フラグのある負の数と取り換え可能か？ +    swap_pos_to_neg = [] +    for i in range(K, N): +        if ls[i] > 0: +            for j in range(K): +                if ls[K - 1 - j] < 0: +                    swap_pos_to_neg = [i, K - 1 - j, -ls[K - 1 - j], ls[i]] -    if a == [0, 0, 0, 0]: +    # フラグを修正 +    if swap_neg_to_pos != [] and swap_pos_to_neg != []:  # どちらも取り換え可能なとき +        # 負の数にフラグを与えたほうがロスが少ないとき +        if ( +            swap_neg_to_pos[2] * swap_pos_to_neg[3] +            < swap_pos_to_neg[2] * swap_neg_to_pos[3] +        ): +            flag[swap_neg_to_pos[0]] = 1 +            flag[swap_neg_to_pos[1]] = 0 +        else:  # 正の数にフラグを与えたほうがロスが少ないとき +            flag[swap_pos_to_neg[0]] = 1 +            flag[swap_pos_to_neg[1]] = 0 +    elif swap_neg_to_pos == [] and swap_pos_to_neg == []:  # どちらも取り換え不可能なとき -    elif b[0] == 0 and b[1] == 0: -        flag[b[2]] = 1 -        flag[b[3]] = 0 -    elif b[2] == 0 and b[3] == 0: -        flag[b[0]] = 1 -        flag[b[1]] = 0 -    elif abs(a[0] * a[3]) > abs(a[1] * a[2]): -        flag[b[0]] = 1 -        flag[b[1]] = 0 -    else: -        flag[b[2]] = 1 -        flag[b[3]] = 0 -if sign == 1 and a == [0, 0, 0, 0] and zeroflag == 1: -    print((0)) -else: -    mul = 1 -    for i in range(N): -        if flag[i] == 1: -            mul = mul * ls[i] % MOD -    print(mul) +    elif swap_pos_to_neg != []:  # 正の数にフラグを与えることのみ可能なとき +        flag[swap_pos_to_neg[0]] = 1 +        flag[swap_pos_to_neg[1]] = 0 +    else:  # 負の数にフラグを与えることのみ可能なとき +        flag[swap_neg_to_pos[0]] = 1 +        flag[swap_neg_to_pos[1]] = 0 +ans = 1 +for i in range(N): +    if flag[i] == 1: +        ans = (ans * ls[i]) % MOD +print(ans)