#include <bits/stdc++.h>
using namespace std;
int n,x;
int a[1005];
void work()
{
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
cin>>x;
if(x<a[1])
{
cout<<x<<" ";
for(int i=1;i<=n;i++) cout<<a[i]<<" ";
return;
}
if(x>a[n])
{
for(int i=1;i<=n;i++) cout<<a[i]<<" ";
cout<<x;
return;
}
int low=lower_bound(a+1,a+1+n,x)-a;
for(int i=1;i<low;i++) cout<<a[i]<<" ";
cout<<x<<" ";
for(int i=low;i<=n;i++) cout<<a[i]<<" ";
}
int main()
{
work();
return 0;
}