#include <iostream>
using namespace std;
const int MAX_LENGTH = 1000;
int main() {
int n, v[MAX_LENGTH + 1];
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> v[i];
}
for (int i = 1; i <= n; ++i) {
if (v[i] % 2 == 0) {
cout << v[i] << ' ';
}
}
for (int i = n; i >= 1; --i) {
if (v[i] % 2 != 0) {
cout << v[i] << ' ';
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1BWF9MRU5HVEggPSAxMDAwOwoKaW50IG1haW4oKSB7CiAgICBpbnQgbiwgdltNQVhfTEVOR1RIICsgMV07CiAgICBjaW4gPj4gbjsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47ICsraSkgewogICAgICAgIGNpbiA+PiB2W2ldOwogICAgfQogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgKytpKSB7CiAgICAgICAgaWYgKHZbaV0gJSAyID09IDApIHsKICAgICAgICAgICAgY291dCA8PCB2W2ldIDw8ICcgJzsKICAgICAgICB9CiAgICB9CiAgICBmb3IgKGludCBpID0gbjsgaSA+PSAxOyAtLWkpIHsKICAgICAgICBpZiAodltpXSAlIDIgIT0gMCkgewogICAgICAgICAgICBjb3V0IDw8IHZbaV0gPDwgJyAnOwogICAgICAgIH0KICAgIH0KICAgIHJldHVybiAwOwp9