using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

static class Program
{
    class Modular
    {
        private const int M = 1000000007;
        private long value;
        public Modular(long value) { this.value = value; }
        public static implicit operator Modular(long a)
        {
            var m = a % M;
            return new Modular((m < 0) ? m + M : m);
        }
        public static Modular operator +(Modular a, Modular b)
        {
            return a.value + b.value;
        }
        public static Modular operator -(Modular a, Modular b)
        {
            return a.value - b.value;
        }
        public static Modular operator *(Modular a, Modular b)
        {
            return a.value * b.value;
        }
        private static Modular Pow(Modular a, int n)
        {
            switch (n)
            {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                var p = Pow(a, n / 2);
                return p * p * Pow(a, n % 2);
            }
        }
        public static Modular operator /(Modular a, Modular b)
        {
            return a * Pow(b, M - 2);
        }
        private static readonly List<int> facs = new List<int> { 1 };
        private static Modular Fac(int n)
        {
            for (int i = facs.Count; i <= n; ++i)
            {
                facs.Add((int)(Math.BigMul(facs.Last(), i) % M));
            }
            return facs[n];
        }
        public static Modular Ncr(int n, int r)
        {
            return (n < r) ? 0
                 : (n == r) ? 1
                            : Fac(n) / (Fac(r) * Fac(n - r));
        }
        public static explicit operator int(Modular a)
        {
            return (int)a.value;
        }
    }

    static int Solve(int N, int K, int[] A)
    {
        var tuples = Array.ConvertAll(A, a => Tuple.Create(Math.Abs(a), (a < 0) ? -1 : 1));
        Array.Sort(tuples, (a, b) => b.Item1.CompareTo(a.Item1));

        if (tuples.Take(K).Count(t => t.Item2 < 0) % 2 == 0)
        {
            return (int)tuples.Take(K).Aggregate(new Modular(1), (a, b) => a * (b.Item1 * b.Item2));
        }
        else if (K == N || tuples.All(t => t.Item2 < 0))
        {
            return (int)tuples.Skip(N - K).Aggregate(new Modular(1), (a, b) => a * (b.Item1 * b.Item2));
        }
        else
        {
            Tuple<int, int> n1 = null;
            Tuple<int, int> n2 = null;
            Tuple<int, int> d1 = null;
            Tuple<int, int> d2 = null;
            for (int i = K - 1; i >= 0; --i)
            {
                if (d1 == null && tuples[i].Item2 < 0)
                {
                    d1 = tuples[i];
                }
                if (d2 == null && tuples[i].Item2 > 0)
                {
                    d2 = tuples[i];
                }
            }
            for (int i = K; i < N; ++i)
            {
                if (n1 == null && tuples[i].Item2 > 0)
                {
                    n1 = tuples[i];
                }
                if (n2 == null && tuples[i].Item2 < 0)
                {
                    n2 = tuples[i];
                }
            }

            var ans = tuples.Take(K).Aggregate(new Modular(1), (a, b) => a * (b.Item1 * b.Item2));
            if (n1 == null || d1 == null)
            {
                ans *= (n2.Item1 * n2.Item2);
                ans /= (d2.Item1 * d2.Item2);
            }
            else if (n2 == null || d2 == null)
            {
                ans *= (n1.Item1 * n1.Item2);
                ans /= (d1.Item1 * d1.Item2);
            }
            else if (Math.BigMul(n1.Item1, d2.Item1) < Math.BigMul(n2.Item1, d1.Item1))
            {
                ans *= (n2.Item1 * n2.Item2);
                ans /= (d2.Item1 * d2.Item2);
            }
            else
            {
                ans *= (n1.Item1 * n1.Item2);
                ans /= (d1.Item1 * d1.Item2);
            }
            return (int)ans;
        }
    }

    static void Main(string[] args)
    {
        var V = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var A = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Console.WriteLine(Solve(V[0], V[1], A));
    }
}


Measured memory_bytes: 47660