MOD = 10**9+7

N,K = gets.split.map &:to_i
A = gets.split.map(&:to_i).sort_by{_1.abs}

if K%2==1 && A.all?{_1<0} then
    p A[0..K-1].inject(1){|r,i| (r*i)%MOD}
    exit
end

A.reverse!
neg_count = A[0..K-1].count{_1<0}

if neg_count%2 == 1 then
    last_neg_idx = A[0..K-1].rindex{_1<0}
    last_pos_idx =  A[0..K-1].rindex{_1>=0}

    next_neg_idx = A[K..-1].index{_1<0}
    next_pos_idx = A[K..-1].index{_1>=0}

    next_neg_idx += K if next_neg_idx
    next_pos_idx += K if next_pos_idx

    swap_neg = next_pos_idx && A[next_pos_idx]/A[last_neg_idx].abs
    swap_pos = next_neg_idx && last_pos_idx && A[next_neg_idx].abs/A[last_pos_idx]
    neg = (swap_neg && swap_pos) ? swap_neg >= swap_pos : swap_neg

    if neg then
        A[last_neg_idx] = A[next_pos_idx]
    else
        A[last_pos_idx] = A[next_neg_idx]
    end
end

 p A[0..K-1].inject(1){|r,i| (r*i)%MOD}