#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n;
cin >> n;
vector <int> v, v2;
int x;
while(cin>>x) v.push_back(x);
int min = v[0];
for(int q=1; q<n; q++) {
if(v[q]<min) min = v[q];
}
int min_counter = 0;
for(int w=0; w<n; w++) {
if(v[w] == min) min_counter++;
}
for(int e=0; e<min_counter; e++) v2.push_back(min);
for(int r=0; r<n; r++) {
if(v[r]!=min) v2.push_back(v[r]);
}
for(int t=0; t<n; t++) cout << v2[t] << " ";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKQp7CiAgICBpbnQgbjsKICAgIGNpbiA+PiBuOwogICAgdmVjdG9yIDxpbnQ+IHYsIHYyOwogICAgaW50IHg7CiAgICB3aGlsZShjaW4+PngpIHYucHVzaF9iYWNrKHgpOwogICAgaW50IG1pbiA9IHZbMF07CiAgICBmb3IoaW50IHE9MTsgcTxuOyBxKyspIHsKICAgICAgICBpZih2W3FdPG1pbikgbWluID0gdltxXTsKICAgIH0KCiAgICBpbnQgbWluX2NvdW50ZXIgPSAwOwogICAgZm9yKGludCB3PTA7IHc8bjsgdysrKSB7CiAgICAgICAgaWYodlt3XSA9PSBtaW4pIG1pbl9jb3VudGVyKys7CiAgICB9CgogICAgZm9yKGludCBlPTA7IGU8bWluX2NvdW50ZXI7IGUrKykgdjIucHVzaF9iYWNrKG1pbik7CiAgICBmb3IoaW50IHI9MDsgcjxuOyByKyspIHsKICAgICAgICBpZih2W3JdIT1taW4pIHYyLnB1c2hfYmFjayh2W3JdKTsKICAgIH0KICAgIGZvcihpbnQgdD0wOyB0PG47IHQrKykgY291dCA8PCB2Mlt0XSA8PCAiICI7CiAgICByZXR1cm4gMDsKfQ==