#include <bits/stdc++.h>
using namespace std;
int n;
int a[200005];
bool visx[200005];
bool visy[200005];
int x[200005];
int y[200005];
int z[200005];
int ansx, ansy, ansz;
int main() {
  cin >> n;
  int m;
  for (int i = 1; i <= n; i++) {
    cin >> m;
    if (m != 0) {
      a[i] = m;
      visy[m] = 1;
      visx[i] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!visx[i] && !visy[i]) {
      z[++ansz] = i;
    } else if (!visx[i]) {
      x[++ansx] = i;
    } else if (!visy[i]) {
      y[++ansy] = i;
    }
  }
  for (int i = 1; i < ansx; i++) {
    a[x[i]] = y[i];
  }
  if (ansz >= 2) {
    a[x[ansx]] = y[ansy];
    for (int i = 1; i < ansz; i++) {
      a[z[i]] = z[i + 1];
    }
    a[z[ansz]] = z[1];
  } else if (ansz == 0) {
    a[x[ansx]] = y[ansy];
  } else {
    a[z[1]] = y[ansy];
    a[x[ansx]] = z[1];
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << " ";
  }
  return 0;
}
