#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  cin >> n;
  int a[n + 1];
  vector<int> b, d, c(n + 1, 0), e;
  for (i = 1; i != n + 1; i++) {
    cin >> a[i];
    c[a[i]] = 1;
    if (a[i] == 0) d.push_back(i);
  }
  for (i = 1; i != n + 1; i++) {
    if (c[i] != 1) b.push_back(i);
  }
  int con = 0, sz = b.size();
  for (i = 0; i != sz; i++) {
    a[d[i]] = b[i];
  }
  for (i = 1; i != n + 1; i++) {
    if (a[i] == i) e.push_back(i);
  }
  int s = e.size();
  i = 0;
  if (s == 1) {
    while (d[i] == e[0]) i++;
    swap(a[e[0]], a[d[i]]);
  }
  for (i = 0; i < s - 1; i++) {
    swap(a[e[i]], a[e[(i + 1)]]);
  }
  for (i = 1; i != n + 1; i++) {
    cout << a[i] << ' ';
  }
}
