using System;

namespace workspace{
  class Program{
    static void Main(){
      var tmp = Console.ReadLine.Split(' ').Select(s => int.Parse(s)).ToList();
      var N = tmp[0];
      var K = tmp[1];
      var price = Console.ReadLine().Split(' ').Select(s => int.Parce(s)).ToList();
      price = price.Sort();
      var sum = 0;
      
      for(int i = 0; i<K; i++){
        sum = sum + price[i];
      }
      Console.WriteLine(price);
    }
  }
}