#include <bits/stdc++.h>
using namespace std;
int n;
int a[202020], b[202020];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i]) b[a[i]] = 1;
  }
  deque<int> t1, t2, t3;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0) {
      if (b[i])
        t3.push_back(i);
      else
        t1.push_back(i);
    } else if (a[i] && !b[i])
      t2.push_back(i);
  }
  if (t1.size() >= 2) {
    deque<int> tmp(t1);
    tmp.push_back(tmp.front());
    tmp.pop_front();
    for (int i = 0; i < t1.size(); i++) {
      a[t1[i]] = tmp[i];
    }
    for (int i = 0; i < t2.size(); i++) {
      a[t3[i]] = t2[i];
    }
  } else if (t1.size() == 0) {
    for (int i = 0; i < t2.size(); i++) {
      a[t3[i]] = t2[i];
    }
  } else {
    a[t3[0]] = t1[0];
    t3.pop_front();
    t3.push_back(t1[0]);
    for (int i = 0; i < t2.size(); i++) {
      a[t3[i]] = t2[i];
    }
  }
  for (int i = 1; i <= n; i++) cout << a[i] << ' ';
  cout << '\n';
  return 0;
}
