local mod = 1000000007

local function bmul(x, y)
  return (x * y) % mod
end

local function badd(x, y)
  return (x + y) % mod
end

local function bsub(x, y)
  return x < y and x - y + mod or x - y
end

local n, k = io.read("*n", "*n")
local plus = {}
local minus = {}
for i = 1, n do
  local a = io.read("*n")
  if 0 <= a then
    table.insert(plus, a)
  else
    table.insert(minus, -a)
  end
end
table.sort(plus)
table.sort(minus)
if n == k then
  local ans = 1
  for i = 1, #plus do
    ans = bmul(ans, plus[i])
  end
  for i = 1, #minus do
    ans = bmul(ans, mod - minus[i])
  end
  print(ans)
  os.exit()
elseif #plus == 0 and k % 2 == 0 then
  local ans = 1
  for i = 1, k do
    ans = bmul(ans, mod - minus[#minus + 1 - i])
  end
  print(ans)
  os.exit()
elseif #plus == 0 and k % 2 == 1 then
  local ans = 1
  for i = 1, k do
    ans = bmul(ans, mod - minus[i])
  end
  print(ans)
  os.exit()
end
local ans = 1
local ppos, mpos = #plus, #minus
if k % 2 == 1 then
  ans = plus[#plus]
  k = (k - 1) // 2
  ppos = #plus - 1
else
  k = k // 2
end
do
  for i = 1, k do
    if ppos < 2 then
      ans = bmul(ans, bmul(minus[mpos], minus[mpos - 1]))
      mpos = mpos - 2
    elseif mpos < 2 then
      ans = bmul(ans, bmul(plus[ppos], plus[ppos - 1]))
      ppos = ppos - 2
    else
      local t1 = minus[mpos] * minus[mpos - 1]
      local t2 = plus[ppos] * plus[ppos - 1]
      if t1 < t2 then
        ans = bmul(ans, (t2 % mod))
        ppos = ppos - 2
      else
        ans = bmul(ans, (t1 % mod))
        mpos = mpos - 2
      end
    end
  end
  print(ans)
end
