#include <bits/stdc++.h>
using namespace std;
unordered_map<int, int> mp;
priority_queue<int> le;
priority_queue<int, vector<int>,
greater<int>> chan;
int main()
{
int n;
cin >> n;
for(int i = 1; i <= n; i++)
{
int c;
cin >> c;
if(c % 2)
mp[i] = 1, le.push(c);
else
chan.push(c);
}
for(int i = 1; i <= n; i++)
{
if(mp[i])
{
cout << le.top() << ' ';
le.pop();
continue;
}
cout << chan.top() << ' ';
chan.pop();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp1bm9yZGVyZWRfbWFwPGludCwgaW50PiBtcDsKcHJpb3JpdHlfcXVldWU8aW50PiBsZTsKcHJpb3JpdHlfcXVldWU8aW50LCB2ZWN0b3I8aW50PiwKICAgICAgICAgICAgICAgZ3JlYXRlcjxpbnQ+PiBjaGFuOwoKaW50IG1haW4oKQp7CiAgICBpbnQgbjsKICAgIGNpbiA+PiBuOwogICAgZm9yKGludCBpID0gMTsgaSA8PSBuOyBpKyspCiAgICB7CiAgICAgICAgaW50IGM7CiAgICAgICAgY2luID4+IGM7CiAgICAgICAgaWYoYyAlIDIpCiAgICAgICAgICAgIG1wW2ldID0gMSwgbGUucHVzaChjKTsKICAgICAgICBlbHNlCiAgICAgICAgICAgIGNoYW4ucHVzaChjKTsKICAgIH0KICAgIGZvcihpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKQogICAgewogICAgICAgIGlmKG1wW2ldKQogICAgICAgIHsKICAgICAgICAgICAgY291dCA8PCBsZS50b3AoKSA8PCAnICc7CiAgICAgICAgICAgIGxlLnBvcCgpOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgY291dCA8PCBjaGFuLnRvcCgpIDw8ICcgJzsKICAgICAgICBjaGFuLnBvcCgpOwogICAgfQogICAgcmV0dXJuIDA7Cn0K