#include <bits/stdc++.h>

using namespace std;

int main() {
    ifstream in("prizes.in");
    ofstream out("prizes.out");
    int n;
    in >> n;
    multiset<int> ma;
    int x, y;
    in >> x >> y;
    ma.insert(x);
    ma.insert(y);
    for (int i = 1; i < n; i++) {
        out << *ma.begin() << " ";
        in >> x;
        ma.insert(x);
        ma.erase(ma.begin());
    }
    return 0;
}
