#include <iostream>
#include <algorithm>
using namespace std;
bool cmp(int v1, int v2)
{
if(v1%2==0&&v2%2==1)
{
return true;
}
if(v1%2==0&&v2%2==0)
{
if(v2>v1)
{
return true;
}
}
if(v1%2==1&&v2%2==1)
{
if(v1>v2)
{
return true;
}
}
return false;
}
int main()
{
int n;
cin>>n;
int a[n];
for (int i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n,cmp);
for (int i=0;i<n;i++)
{
cout<<a[i]<<" ";
}
}