#include <bits/stdc++.h>
using namespace std;
bool ch(vector<int>& b, vector<int>& d) {
  for (int i = 0; i < b.size(); i++) {
    if (b[i] == d[i]) return true;
  }
  return false;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b;
  vector<bool> c(n, true);
  vector<int> d;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0)
      b.push_back(i + 1);
    else
      c[a[i] - 1] = false;
  }
  for (int i = 0; i < n; i++) {
    if (c[i]) d.push_back(i + 1);
  }
  if (!ch(b, d)) {
    for (int i = 0; i < b.size(); i++) a[b[i] - 1] = d[i];
  } else {
    while (ch(b, d)) {
      int ex = d[0];
      for (int i = 0; i < d.size() - 1; i++) {
        d[i] = d[i + 1];
      }
      d[d.size() - 1] = ex;
    }
  }
  for (int i = 0; i < b.size(); i++) a[b[i] - 1] = d[i];
  for (int i = 0; i < n; i++) cout << a[i] << " ";
}
