#include
using namespace std;
int main() {
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
int s=0;
int e=n-1;
int mid=0;
while(s<=e){
if(arr[mid]==0){
swap(arr[s++],arr[mid++]);
}
else if(arr[mid] == 1){
mid++;
}
else {
swap(arr[e--], arr[mid]);
}
}
for(int i=0;i<n;i++){
cout<<arr[i]<<endl;
}
return 0;
}