// Mohib Manva.
#include <bits/stdc++.h>
using namespace std;
vector<int> vc;
int n;
int S = 16;
void solve(int ind) {
if (ind == n) {
vector<int> tmp;
for (int x : vc) {
tmp.push_back(x);
}
sort(tmp.begin(), tmp.end());
bool ok = true;
int sum = 0;
for (int i = 0; i < n;i ++) {
ok &= (tmp[i] == (i + 1));
if (i % 2) {
sum += abs(vc[i] - vc[i-1]);
}
}
// for (int x : vc) {
// printf("%d ", x);
// }
// puts("");
if (ok && sum == S) {
for (int x : vc) {
printf("%d ", x);
}
puts("");
}
return;
}
if (vc[ind] != 0) {
solve(ind+1);
} else {
for (int i = 1; i <= n;i++) {
vc[ind] = i;
solve(ind + 1);
vc[ind] = 0;
}
}
}
int main() {
int t = 1;
// scanf("%d",&t);
while (t--) {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
int x;
scanf("%d", &x);
vc.push_back(x);
}
solve(0);
}
return 0;
}
Ly8gTW9oaWIgTWFudmEuCiNpbmNsdWRlIDxiaXRzL3N0ZGMrKy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdmVjdG9yPGludD4gdmM7CmludCBuOwppbnQgUyA9IDE2OwoKdm9pZCBzb2x2ZShpbnQgaW5kKSB7CiAgICBpZiAoaW5kID09IG4pIHsKICAgICAgICB2ZWN0b3I8aW50PiB0bXA7CiAgICAgICAgZm9yIChpbnQgeCA6IHZjKSB7CiAgICAgICAgICAgIHRtcC5wdXNoX2JhY2soeCk7CiAgICAgICAgfQogICAgICAgIHNvcnQodG1wLmJlZ2luKCksIHRtcC5lbmQoKSk7CiAgICAgICAgYm9vbCBvayA9IHRydWU7CiAgICAgICAgaW50IHN1bSA9IDA7CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuO2kgKyspIHsKICAgICAgICAgICAgb2sgJj0gKHRtcFtpXSA9PSAoaSArIDEpKTsKICAgICAgICAgICAgaWYgKGkgJSAyKSB7CiAgICAgICAgICAgICAgICBzdW0gKz0gYWJzKHZjW2ldIC0gdmNbaS0xXSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgLy8gIGZvciAoaW50IHggOiB2YykgewogICAgICAgIC8vICAgICAgICAgcHJpbnRmKCIlZCAiLCB4KTsKICAgICAgICAvLyAgICAgfQogICAgICAgIC8vICAgICBwdXRzKCIiKTsKICAgICAgICBpZiAob2sgJiYgc3VtID09IFMpIHsKICAgICAgICAgICAgZm9yIChpbnQgeCA6IHZjKSB7CiAgICAgICAgICAgICAgICBwcmludGYoIiVkICIsIHgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHB1dHMoIiIpOwogICAgICAgIH0KICAgICAgICByZXR1cm47CiAgICB9CiAgICAKICAgIGlmICh2Y1tpbmRdICE9IDApIHsKICAgICAgICBzb2x2ZShpbmQrMSk7CiAgICB9IGVsc2UgewogICAgICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47aSsrKSB7CiAgICAgICAgICAgIHZjW2luZF0gPSBpOwogICAgICAgICAgICBzb2x2ZShpbmQgKyAxKTsKICAgICAgICAgICAgdmNbaW5kXSA9IDA7CiAgICAgICAgfQogICAgfQp9CgppbnQgbWFpbigpIHsKCWludCB0ID0gMTsKLy8gCXNjYW5mKCIlZCIsJnQpOwoJd2hpbGUgKHQtLSkgewoJCXNjYW5mKCIlZCIsICZuKTsKCQlmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykgewoJCSAgICBpbnQgeDsKCQkgICAgc2NhbmYoIiVkIiwgJngpOwoJCSAgICB2Yy5wdXNoX2JhY2soeCk7CgkJfQoJCQoJCXNvbHZlKDApOwoJCQoJfQoJcmV0dXJuIDA7Cn0=