#include "bits/stdc++.h"
#define puba push_back
#define mapa make_pair
#define ff first
#define ss second
#define bend(_x) (_x).begin(), (_x).end()
#define szof(_x) ((int) (_x).size())
#define TASK_NAME "prizes"

using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
const int MAXN = 1e5 + 5;

int n;
int arr[MAXN];

int main() {        
    freopen(TASK_NAME ".in", "r", stdin);
    freopen(TASK_NAME ".out", "w", stdout);

    scanf("%d", &n);

    scanf("%d", arr);

    for (int i = 1; i < n; ++i) {
        int num;
        scanf("%d", &num);
        int j = i - 1;
        while (j >= 0 && arr[j] > num) {
            arr[j + 1] = arr[j];
            --j;
        }
        cerr << j << endl;
        arr[j + 1] = num;
        if (i) {
            cout << arr[i - 1] << " ";
        }
    }
    cout << "\n";

    return 0;
}