#include <iostream>

using namespace std;

int main()
{
    int n;
    int arr1[50] = { 0 };
    int arr2[50] = { 0 };
    int digit;
    while (cin >> n)
    {
        for (int i = 0; i < n; i++)
        {
            cin >> arr1[i];;
        }
        cin >> digit;
        if (digit >= arr1[n - 1])
        {
            arr2[n] = digit;
            for (int i = 0; i < n; i++)
            {
                arr2[i] = arr1[i];
            }
        }
        else
        {
            for (int i = 0; i < n; i++)
            {
                if (digit <= arr1[i])
                {
                    for (int j = i + 1; j < n + 1; j++)
                    {
                        arr2[j] = arr1[j-1];
                    }
                    arr2[i] = digit;
                    for (int k = 0; k < i; k++)
                    {
                        arr2[k] = arr1[k];
                    }
                    break;
                }
            }
        }
        for (int i = 0; i < n + 1; i++)
        {
            cout << arr2[i] << " ";
        }
    }
    return 0;
}