output_description: Print the maximum product modulo (10^9+7), using an integer between 0 and
  10^9+6 (inclusive).
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
      A_1 \ldots A_N
attempt: import bisect
  import sys
  
  input = sys.stdin.readline
  
  
  def main(args):
      n, k = map(int, input().split())
      A = list(map(int, input().split()))
  
      A.sort()
  
      minus = bisect.bisect_right(A, -1)
      zeros = bisect.bisect_right(A, 0) - minus
      plus = n - (minus + zeros)
  
      mA = A[:minus]
      pA = A[minus + zeros :]
  
      mod = 10**9 + 7
      # print("pArev",pA[::-1])
      # print("mA",mA)
  
      # 正の値が一個もないとき
      if plus == 0:
          if k % 2 == 1:  # 負の数を奇数個とらなきゃならないとき
              if zeros > 0:  # ゼロがあれば
                  print(0)
              else:  # ゼロがないとき
                  ans = 1
                  for i in range(k):
                      ans = ans * mA[-(i + 1)] % mod
                  print(ans)
          else:  # 負の数を偶数個とらなきゃならないとき
              ans = 1
              for i in range(k):
                  ans = ans * mA[i] % mod
              print(ans)
      else:  # 正の値が一個でもあれば
          pickm = 0  # マイナスからとってきた個数
          pickp = 0  # プラスからとってきた個数
          indm = 0
          indp = 0
          pA.sort(reverse=True)
          ans = 1
          if minus > 0:
              if k % 2 == 1:  # 正から必ず奇数個とるとき
                  while pickm + pickp < k:
                      if pickm + pickp == k - 1 and pickp % 2 == 0:
                          ans = ans * pA[indp] % mod
                          break
                      if abs(pA[indp]) > abs(mA[indm]):
                          ans = ans * pA[indp] % mod
                          indp += 1
                          pickp += 1
                      else:
                          ans = ans * mA[indm] % mod
                          indm += 1
                          pickm += 1
              else:  # 正から必ず偶数個（０含む）とるとき
                  while pickm + pickp < k:
                      if pickm + pickp == k - 1:
                          if pickp % 2 == 0:
                              ans = ans * mA[indm] % mod
                              break
                          else:
                              ans = ans * pA[indp] % mod
                              break
                      if abs(pA[indp]) > abs(mA[indm]):
                          ans = ans * pA[indp] % mod
                          indp += 1
                          pickp += 1
                      else:
                          ans = ans * mA[indm] % mod
                          indm += 1
                          pickm += 1
          else:
              if plus < k:
                  print(0)
              else:
                  ans = 1
                  for i in range(k):
                      ans = ans * pA[i] % mod
          print(ans % mod)
  
  
  if __name__ == "__main__":
      main(sys.argv[1:])
  
problem_description: Statement
  
  Given are N integers A_1,\ldots,A_N.
  
  We will choose exactly K of these elements. Find the maximum possible product
  of the chosen elements.
  
  Then, print the maximum product modulo (10^9+7), using an integer between 0
  and 10^9+6 (inclusive).
samples: [{"input": "4 2\n    1 2 -3 -4", "output": "12\n    \n\nThe possible products of the two chosen elements are 2, -3, -4, -6, -8, and\n12, so the maximum product is 12.\n\n* * *"}, {"input": "4 3\n    -1 -2 -3 -4", "output": "1000000001\n    \n\nThe possible products of the three chosen elements are -24, -12, -8, and -6,\nso the maximum product is -6.\n\nWe print this value modulo (10^9+7), that is, 1000000001.\n\n* * *"}, {"input": "2 1\n    -1 1000000000", "output": "1000000000\n    \n\nThe possible products of the one chosen element are -1 and 1000000000, so the\nmaximum product is 1000000000.\n\n* * *"}, {"input": "10 10\n    1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1", "output": "999983200\n    \n\nBe sure to print the product modulo (10^9+7)."}]