#include <bits/stdc++.h>
using namespace std;

class Node{
	public:
	int data;
	Node* next;
	
	Node(int d){
		data = d;
		next = NULL;
	}
};

void insert(Node*& head, int data){
	
	if(head == NULL){
		head = new Node(data);
		return;
	}
	
	Node* temp = head;
	while(temp->next != NULL){
		temp = temp->next;
	}
	temp->next = new Node(data);
	
}


void print(Node* head){
	while(head!=NULL){
		cout<<head->data<<" ";
		head = head->next;
	}
	cout<<endl;
}

void evenAfterOdd(Node*& head){
	// To check the approach I took just read the comments at the end of the prog
	
	Node* evenLast = NULL, *evenFirst = NULL, *oddLast = NULL;
	
	Node* temp = head;
	
	while(temp!=NULL){
		
		if(temp->data%2 == 0){
			if(evenFirst == NULL){
				evenFirst = temp;
				evenLast = temp;
			}else{
				evenLast->next = temp;
				evenLast = temp;
			}
		}else{
			if(oddLast == NULL){
				head = temp;
				oddLast = temp;
			}else{
				oddLast->next = temp;
				oddLast = temp;
			}
		}
		temp = temp->next;
	}
	
	oddLast->next = evenFirst;
	evenLast->next = NULL;
}

int main() {
	Node* head = NULL;
	int n;
	cin>>n;
	for(int i = 0; i < n; i++){
		int temp;
		cin>>temp;
		insert(head,temp);
	}
	evenAfterOdd(head);
	print(head);
	return 0;
}

	
	// Instead of the above approach I will take 2 node pointers
	// One of them represents the last even node encountered and odd resp
	// We will also store the first of the Even list as we will do
	// oddLast->next = evenFirst