#include <bits/stdc++.h>
using namespace std;

#define sz(x) static_cast<int>((x).size())
#define pb push_back

namespace BST {

  struct Node {
    int value;
    int left, right;
    Node() : left(-1), right(-1) { }
    Node(int value) : value(value), left(-1), right(-1) { }
  };

  vector<Node> m;

  void init() {
    m.clear();
  }

  int rec(int ind, int value) {
    if( ind == -1 ) {
      m.pb(Node(value));
      return sz(m)-1;
    }
    if( value < m[ind].value )
      m[ind].left = rec(m[ind].left, value);
    else
      m[ind].right = rec(m[ind].right, value);
    return ind;
  }

  void push(int value) {
    if( m.empty() ) {
      m.pb(Node(value));
    } else {
      rec(0,value);
    }
  }

  void print(int ind) {
    if( ind != -1 ) {
      print(m[ind].left);
      cout << m[ind].value << " ";
      print(m[ind].right);         
    }
  }

  void print() {
    print(0); cout << "\n";
  }

}

int main() {

  int n;
  while( cin >> n ) {
    BST::init();
    while( n-- ) {
      int t; cin >> t; BST::push(t);
    }
    BST::print();
  }    

  return 0;
}