#include <iostream>
#include <vector>

using namespace std;

int main(){
    int l=1, i=0, n, h;

    cin >> n;
    int a[n];
    for(i = 0; i<n; i++) 
    cin >> a[i];

    while(l < n){

        h = a[l];
        a.erase(a.bigin() + l);
        cout << max(a[i]) << endl;
        a.insert(a.bigin() + l, h);

        l++
    }
}