#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 == 0)
mp[i] = -1;
else if(c % 2)
mp[i] = 1, le.push(c);
else
chan.push(c);
}
for(int i = 1; i <= n; i++)
{
if(mp[i] == -1)
cout << 0 << ' ';
else if(mp[i])
{
cout << le.top() << ' ';
le.pop();
}
else
{
cout << chan.top() << ' ';
chan.pop();
}
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp1bm9yZGVyZWRfbWFwPGludCwgaW50PiBtcDsKcHJpb3JpdHlfcXVldWU8aW50PiBsZTsKcHJpb3JpdHlfcXVldWU8aW50LCB2ZWN0b3I8aW50PiwKICAgICAgICAgICAgICAgZ3JlYXRlcjxpbnQ+PiBjaGFuOwoKaW50IG1haW4oKQp7CiAgICBpbnQgbjsKICAgIGNpbiA+PiBuOwogICAgZm9yKGludCBpID0gMTsgaSA8PSBuOyBpKyspCiAgICB7CiAgICAgICAgaW50IGM7CiAgICAgICAgY2luID4+IGM7CiAgICAgICAgaWYoYyA9PSAwKQogICAgICAgICAgICBtcFtpXSA9IC0xOwogICAgICAgIGVsc2UgaWYoYyAlIDIpCiAgICAgICAgICAgIG1wW2ldID0gMSwgbGUucHVzaChjKTsKICAgICAgICBlbHNlCiAgICAgICAgICAgIGNoYW4ucHVzaChjKTsKICAgIH0KICAgIGZvcihpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKQogICAgewogICAgICAgIGlmKG1wW2ldID09IC0xKQogICAgICAgICAgICBjb3V0IDw8IDAgPDwgJyAnOwogICAgICAgIGVsc2UgaWYobXBbaV0pCiAgICAgICAgewogICAgICAgICAgICBjb3V0IDw8IGxlLnRvcCgpIDw8ICcgJzsKICAgICAgICAgICAgbGUucG9wKCk7CiAgICAgICAgfQogICAgICAgIGVsc2UKICAgICAgICB7CiAgICAgICAgICAgIGNvdXQgPDwgY2hhbi50b3AoKSA8PCAnICc7CiAgICAgICAgICAgIGNoYW4ucG9wKCk7CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIDA7Cn0K