#include <bits/stdc++.h>
using namespace std;
const long long INF = LONG_LONG_MAX;
const long long NINF = LONG_LONG_MIN;
const long long mmod = 998244353;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  long long f[n];
  for (long long& x : f) {
    cin >> x;
  }
  for (long long i = 0; i < n; i++) f[i]--;
  set<long long> s;
  set<long long> zero;
  for (long long i = 0; i < n; i++) {
    s.insert(f[i]);
    if (f[i] == -1) zero.insert(i);
  }
  set<long long> ss;
  for (long long i = 0; i < n; i++) {
    if (s.find(i) == s.end()) ss.insert(i);
  }
  for (long long i = 0; i < n; i++) {
    if (zero.find(i) != zero.end() && ss.find(i) != ss.end()) {
      auto it = ss.begin();
      while (it != ss.end()) {
        if ((*it) == i) {
          it++;
        } else {
          f[i] = (*it);
          ss.erase(it);
          break;
        }
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    if (f[i] == -1) {
      auto it = ss.begin();
      while (it != ss.end()) {
        if ((*it) == i) {
          it++;
        } else {
          f[i] = (*it);
          ss.erase(it);
          break;
        }
      }
    }
  }
  for (long long& x : f) cout << x + 1 << ' ';
  cout << endl;
}
