#include <bits/stdc++.h>
using namespace std;
void solve(vector<int> &nums) {
// Time: O(n * log(n)), Space: O(1)
// sort(nums.begin(), nums.end());
// Time: O(n), Space: O(n)
int zeros = 0, ones = 0, twos = 0;
for (int i = 0; i < nums.size(); i++) {
switch (nums[i]) {
case 0:
zeros++;
break;
case 1:
ones++;
break;
case 2:
twos++;
break;
}
}
for (int i = 0; i < zeros; i++) {
nums[i] = 0;
}
for (int i = zeros; i < zeros + ones; i++) {
nums[i] = 1;
}
for (int i = zeros + ones; i < nums.size(); i++) {
nums[i] = 2;
}
// Time: O(n), Space: O(1)
}
void print(vector<int> &nums) {
for (int i = 0; i < nums.size(); i++) {
cout << nums[i] << " ";
}
cout << endl;
}
int main() {
int n;
cin >> n;
vector<int> nums(n);
for (int i = 0; i < n; i++) {
cin >> nums[i];
}
solve(nums);
print(nums);
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp2b2lkIHNvbHZlKHZlY3RvcjxpbnQ+ICZudW1zKSB7CgkvLyBUaW1lOiBPKG4gKiBsb2cobikpLCBTcGFjZTogTygxKQoJLy8gc29ydChudW1zLmJlZ2luKCksIG51bXMuZW5kKCkpOwoJCgkvLyBUaW1lOiBPKG4pLCBTcGFjZTogTyhuKQoJaW50IHplcm9zID0gMCwgb25lcyA9IDAsIHR3b3MgPSAwOwoJZm9yIChpbnQgaSA9IDA7IGkgPCBudW1zLnNpemUoKTsgaSsrKSB7CgkJc3dpdGNoIChudW1zW2ldKSB7CgkJCWNhc2UgMDoKCQkJCXplcm9zKys7CgkJCQlicmVhazsKCQkJY2FzZSAxOgoJCQkJb25lcysrOwoJCQkJYnJlYWs7CgkJCWNhc2UgMjoKCQkJCXR3b3MrKzsKCQkJCWJyZWFrOwoJCX0KCX0KCWZvciAoaW50IGkgPSAwOyBpIDwgemVyb3M7IGkrKykgewoJCW51bXNbaV0gPSAwOwoJfQoJZm9yIChpbnQgaSA9IHplcm9zOy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