#include
using namespace std;
class node
{
public:
int data;
node *next;
node(int d)
{
this->data = d;
this->next = NULL;
}
};
void insertattail (node *&tail, node *&head, int d)
{
if (tail == NULL)
{
tail = new node(d);
head = tail;
}
else
{
node *temp = new node(d);
tail->next = temp;
tail = temp;
}
}
void print(node *head)
{
while (head != NULL)
{
cout << head->data << " ";
head = head->next;
}
cout << endl;
}
void insertathead(node *&head, node *&tail, int d)
{
if (head == NULL)
{
head = new node(d);
tail = head;
return;
}
node *temp = new node(d);
temp->next = head;
head = temp;
}
int main()
{
int n;
cin >> n;
node *tail = NULL;
node *head = NULL;
while (n–)
{
int d;
cin >> d;
if (d % 2 != 0)
{
insertathead(head, tail, d);
}
else
insertattail(tail, head, d);
}
//even_odd(head, tail);
print(head);
return 0;
}