#include <bits/stdc++.h>
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,abm,mmx,avx,avx2,popcnt,tune=native")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long mod = 1e9 + 7;
const long double eps = 1e-6;
const long long inf = 1e18;
const int base = 1e9;
const long double PI = 3.1415926;
void deb(long double first){};
long long n;
int f[2 * 100 * 1000 + 1];
bool u[2 * 100 * 1000 + 1];
set<int> to, from;
unsigned int bitcount(unsigned long long val) {
  return __builtin_popcount(val) + __builtin_popcount(val >> 32);
}
void local() { freopen("test.in", "r", stdin); }
void remote() {}
void read() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n;
  fill(u, u + n + 1, false);
  for (long long i = 1; i < n + 1; i++) to.insert(i), from.insert(i);
  for (long long i = 1; i < n + 1; i++) {
    cin >> f[i];
    if (f[i] != 0) {
      u[i] = u[f[i]] = true;
      to.erase(i);
      from.erase(f[i]);
    }
  }
}
void gen() {}
int main() {
  remote();
  read();
  for (long long i = 1; i < n + 1; i++) {
    if (!u[i]) {
      to.erase(i);
      auto it = from.begin();
      while (*it == i) it++;
      f[i] = *it;
      from.erase(f[i]);
      u[f[i]] = true;
    }
  }
  while (!to.empty()) {
    int v = *to.begin();
    to.erase(v);
    auto it = from.begin();
    while (*it == v) it++;
    f[v] = *it;
    from.erase(f[v]);
  }
  for (long long i = 0; i < n; i++) cout << f[i + 1] << " ";
}
