#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <list>

// [1,2,3] :: list<int>
// [[1], [2], [3]] :: list<list<int>>
// [[3],,[1,2]]
// ..
// [[1,2,3]]

//tohle neni uplne efektivni implementace, priste ji zefektivnime.
std::list<int> merge (std::list<int> &a, std::list<int> &b) {
  std::list<int> l;
  while(!a.empty() && !b.empty()){
    if(a.front() > b.front()){
      l.push_back(b.front());
      b.pop_front();
    }
    else{
      l.push_back(a.front());
      a.pop_front();
    }
  }
  std::move(a.begin(), a.end(), std::back_inserter(l));
  std::move(b.begin(), b.end(), std::back_inserter(l));
  return l;
}


void mergesort(std::list<int> &lst)
{
  std::list<std::list<int>> ll;
  for(auto && x : lst) {
    std::list<int> temp;
    temp.push_back(x);
    ll.push_back(temp);
    //ll.emplace_back({x});
  }
  
  while(ll.size() > 1) {
    std::list<int> l1 = ll.front();
    ll.pop_front();
    std::list<int> l2 = ll.front();
    ll.pop_front();
    ll.push_back(merge(l1, l2));
  }
  
  lst = ll.front();
}

int main(){
  size_t n = 10;
  std::list<int> lst;

  int num;
  for(size_t i = 0; i < n; i++)
  {
    std::cin>>num;
    lst.push_back(num);
  }

  mergesort(lst);

  for(auto && x : lst)
    std::cout<<x<<" ";
  std::cout<<std::endl;
  return 0;
}

int main3(){
  std::string str;

  std::set<std::string> m;

  while(std::cin >> str)
    m.insert(str);
  
  for(auto && x : m){
    std::cout << x << " ";
  }
  std::cout << std::endl;
  return 0;
}

int main2(){
  std::string str;

  std::map<char, size_t> m;

  while((bool)std::getline(std::cin, str))
    for(size_t i = 0; i < str.size(); i++)
      m[str[i]]++;
  
  for(auto && x : m){
    std::cout << x.first << '\t';
    for(size_t i = 0; i < x.second; i++)
      std::cout << '*';
    std::cout << std::endl;
  }
  return 0;
}






int main1() {
  std::vector<int> vec(5);
  int num;
  for (size_t i = 0; i < vec.size(); ++i) {
    std::cin >> num;
    vec[i] = num;
  }

  int z=5;
  std::sort(vec.begin(), vec.end(), [z](int a, int b){ return a%z<b%z;});
  std::vector<int>::iterator it;

  for(it = vec.begin(); it != vec.end(); ++it){
    std::cout << *it << std::endl;
  }



  // for (auto && x : vec)
  //   std::cout << x;

  std::cout << "Hello World!\n";
  return 0;
}
