
#include <iostream>
using namespace std;
int main()
{
int Lu[100];
int n, x = 0;
while (cin >> n && n < 100)
{
if (n == 0 || n < 0)
break;
for (int i = 0; i < n; i++)
cin >> Lu[i];
int key = Lu[0];
for (int i = 0; i < n; i++)
{
while (Lu[i] <= Lu[x])
++x;
if (x == n)
{
Lu[0] = Lu[i];
Lu[i] = key;
break;
}
}
for (int i = 0; i < n; i++)
cout << Lu[i] << ' ';
cout << endl;
x = 0;
}
return 0;
}