#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,a[101],y,d,w;          
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    cin >> y;
    d = a[0];  
    w = 0;    
    for (int i = 1; i < n; i++) {
        if (a[i] > d) {  
            d = a[i];    
            w = i;       
        }
    }
    for (int i = n; i > w; i--) {
        a[i] = a[i-1];
    }
    a[w + 1] = y;
    for (int i = 0; i < n + 1; i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << a[i];
    }
    cout << endl;
    
    return 0;
}
    
/**************************************************************
	Problem: 1214
	User: cyp
	Language: C++
	Result: Accepted
	Time:8 ms
	Memory:2072 kb
****************************************************************/