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 sys
  
  input = sys.stdin.readline
  
  
  def I():
      return int(input())
  
  
  def MI():
      return map(int, input().split())
  
  
  def LI():
      return list(map(int, input().split()))
  
  
  n, k = MI()
  mylist = LI()
  plus = [i for i in mylist if i >= 0]
  plus.sort(reverse=True)
  minus = [i for i in mylist if i < 0]
  minus.sort()
  mod = 10e9 + 7
  index = k
  result = 1
  
  while index > 0:
      if index == 1:
          if len(plus) != 0:
              result *= plus[0]
              plus = plus[1:]
              index -= 1
          else:
              result *= minus[-1]
              index -= 1
      else:
          if len(plus) == 0:
              if index % 2 == 0:
                  for i in range(index):
                      result *= minus[i]
                  index = 0
              else:
                  index2 = len(minus)
                  for i in range(index):
                      result *= minus[index2 - 1 - i]
                  index = 0
          elif len(plus) == 1:
              if len(minus) >= 2:
                  if minus[0] * minus[1] > plus[1]:
                      result *= minus[0] * minus[1]
                      index -= 2
                      minus = minus[2:]
                  else:
                      result *= plus[0]
                      plus = []
                      index -= 1
              else:
                  result *= plus[0] * minus[0]
                  index -= 2
          else:
              if len(minus) <= 1:
                  result *= plus[0]
                  plus = plus[1:]
                  index -= 1
              else:
                  if minus[0] * minus[1] > plus[0] * plus[1]:
                      result *= minus[0] * minus[1]
                      index -= 2
                      minus = minus[2:]
                  else:
                      result *= plus[0]
                      index -= 1
                      plus = plus[1:]
  print(int(result % mod))
  
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)."}]