#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using namespace std;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long n;
  cin >> n;
  set<long long> ta, gi;
  long long a[n];
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    ta.insert(i + 1);
  }
  for (ll i = 0; i < n; i++) {
    if (a[i] == 0)
      gi.insert(i + 1);
    else if (ta.find(a[i]) != ta.end())
      ta.erase(ta.find(a[i]));
  }
  map<long long, long long> ot;
  auto it = ta.begin();
  auto it1 = gi.rbegin();
  for (; it != ta.end() && it1 != gi.rend(); it++, it1++) ot[*it1] = *it;
  for (auto it = ot.begin(); it != ot.end(); it++) {
    if (it->first == it->second) {
      auto p = it;
      p++;
      if (p != ot.end()) {
        long long x = p->second;
        p->second = it->second;
        it->second = x;
      } else {
        p--;
        p--;
        long long x = p->second;
        p->second = it->second;
        it->second = x;
      }
    }
  }
  for (ll i = 0; i < n; i++) {
    if (a[i] == 0) {
      a[i] = ot[i + 1];
    }
    cout << a[i] << " ";
  }
  return 0;
}
