using System.Collections.Generic;
using System.Numerics;
using System;

namespace once__at_the_end_of_time
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int t;
            int n, target; //lepse zvuci target nego k iskr
            int h = 0; //trenutna
            t = Convert.ToInt32(Console.ReadLine());
            n = Convert.ToInt32(Console.Read());
            target = Convert.ToInt32(Console.Read());
            LinkedList<int> a = new LinkedList<int>();
            List<int> w = new List<int>(); //ako je t==1 w je rezultat
            w[0] = 1;
            for (int i = 0; i < n; i++)
            {
                a.AddFirst(Convert.ToInt32(Console.ReadLine()));
            }

            bool ind = false;
            while (a.Count() > 0 && !ind)
            {
                if (h < target)
                {
                    for (int i = 0; i < (int)(a.Count()) && !ind; i++)
                    {
                        if (a.ElementAt(i) > h)
                        {
                            h++;
                            w.Add(Convert.ToInt32(a.ElementAt(i)));
                            a.Remove(a.ElementAt(i));
                            break;
                        }
                    }
                }
            }
            for(int i = 0; i < n; i++)
            {
                Console.Write(w[i] + " ");
            }
        }
    }
}