#include <stdio.h>

int main() {
    int n = 0;
    int i = 0;
    int num1[51] = {0};
    int num2 = 0;
    scanf("%d",&n);
   
    for(i = 0;i<n;i++)
    {
        scanf("%d ",&num1[i]);
    }
    scanf("%d",&num2);
    
    for(i = n-1;i>=0;i--)
    {
        if(num2 <num1[i])
        {
            num1[i+1]=num1[i];
        }
        else {
        num1[i+1] = num2;
        break;
        }
    }
    if(i<0)
    {
        num1[0]=num2;
    }
    for(i = 0;i<n+1;i++)
    {
        printf("%d ",num1[i]);
    }
    return 0;
}