#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a[200001], ind[200001], cyc[200001];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    ind[i] = 0;
    cyc[i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i]) ind[a[i]] = 1;
  }
  int cou = 0;
  for (int i = 1; i <= n; i++) {
    if (!ind[i] && !a[i]) {
      cyc[cou + 1] = i;
      cou++;
    }
  }
  if (cou != 1 && cou != 0) {
    for (int i = 1; i < cou; i++) {
      a[cyc[i]] = cyc[i + 1];
      ind[cyc[i + 1]] = 1;
    }
    a[cyc[cou]] = cyc[1];
    ind[cyc[1]] = 1;
  } else {
    if (cou == 1) {
      for (int i = 1; i <= n; i++) {
        if (cyc[1] != i && !ind[i]) {
          a[cyc[1]] = i;
          ind[i] = 1;
          break;
        }
      }
    }
  }
  int k = 1;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0) {
      while (ind[k] == 1) {
        k++;
      }
      a[i] = k;
      ind[k] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << ' ';
  }
  return 0;
}
