#include <stdio.h>

int main() {
    int total = 0;
    while (scanf("%d", &total) != EOF) 
    { 
        int arr[51] = {0};
        int num = 0;
        for (int i = 0; i < total; i++)
        {
            scanf("%d",arr +i);
        }
        scanf("%d",&num);
        int flag = 0;
        for (int j = 0; j < total + 1; j++)
        {
            if (arr[total-1] < num)
            {
                arr[total] = num;
            }

            if (arr[j] > num && flag < 1)
            {
                for (int k = total - 1; k >= j; k--)
                {
                    arr[k+1] = arr[k];
                }
                arr[j] = num;
                flag++;
            }
            
            printf("%d ",arr[j]);
        }
    }
    return 0;
}