#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  ;
  long long int a[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  ;
  vector<long long int> f(n + 1, 0);
  for (long long int i = 0; i < n; i++) {
    f[a[i]]++;
  }
  set<long long int> st;
  for (long long int i = 1; i <= n; i++) {
    if (f[i] == 0) {
      st.insert(i);
    }
  }
  for (long long int i = 0; i < n; i++) {
    if (a[i] == 0) {
      if (st.find(i + 1) != st.end()) {
        auto it = st.find(i + 1);
        it++;
        if (it == st.end()) {
          it--;
          it--;
          a[i] = *(it);
          st.erase(it);
        } else {
          a[i] = *(it);
          st.erase(it);
        }
      }
    }
  }
  for (long long int i = 0; i < n; i++) {
    if (a[i] == 0) {
      auto it = st.begin();
      a[i] = *(it);
      st.erase(it);
    }
  }
  for (long long int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
