include<stdio.h>

int main()
{
int a = 0, b = 0, n = 0;
scanf("%d", &n);
int arr[50] = { 0 };
for (; a < n; a++)
{
scanf("%d", &arr[a]);
}
scanf("%d", &b);

for (a = a - 1; a >= 0; a--)
{
    if (arr[a] < b) { arr[a + 1] = b; break; }
    if (b > arr[a - 1])
{
        arr[a+1] = arr[a];
    arr[a] = b;
    break;
}
    if (arr[a] > b)
    {
        arr[a + 1] = arr[a];
    }
    //
    //else
    //    arr[a+1]=b;
    if (a == 0)
        arr[0] = b;
}
for (int i = 0; i < n+1; i++)
    printf("%d ", arr[i]);
return 0;

}