#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main () {
int N;
cin >> N;
vector<int> nums(N, 0);
for (int i = 0; i < N; ++i) {
cin >> nums[i];
}
int left = -1, right = N, index = 0;
// while (index < right) {
// if (nums[index] == 0) {
// swap(nums[++left], nums[index++]);
// } else if (nums[index] == 2) {
// swap(nums[--right], nums[index]);
// } else {
// index++;
// }
// }
// for (auto iter : nums) {
// cout << iter << " ";
// }
// return 0;
//============================总结===========================
//总结一般性,给定一个数组和target,小于target放在左边,等于target放在中间,大于target放在右边
//左边分为小于区,右边分为大于区,
//1、当前值小于target则往小于区发货,当前值与小于区的下一个位置交换,小于区扩充一个位置,当前索引值++;
//2、当前值大于target则往大于区发货,当前值与大于区的前一个位置交换,大于区扩充一个位置,当前索引值不变
//3、当前值等于target,当前索引值++;
while (index < right) {
if (nums[index] < 1) {
swap(nums[++left], nums[index++]);
} else if (nums[index] > 1) {
swap(nums[--right], nums[index]);
} else {
index++;
}
}
for (auto iter : nums) {
cout << iter << " ";
}
return 0;
}