#include <iostream> #include <list> #include <algorithm> using namespace std; int main() { int n; cin >> n; list<int> l; while (n--) { int m; cin >> m; auto it = l.begin(); while (it != l.end() && *it < m) it++; l.insert(it, m); } for_each(l.begin(), l.end(), [](int x) { cout << x << ' '; }); return 0; }