#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> f(n + 1);
  vector<bool> flg(n + 1, false);
  vector<int> ind;
  vector<int> pr;
  for (int i = 1; i <= n; i++) {
    cin >> f[i];
    flg[f[i]] = true;
    if (f[i] == 0) {
      ind.push_back(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!flg[i]) {
      pr.push_back(i);
    }
  }
  int s = pr.size();
  for (int i = 0; i < s - 1; i++) {
    if (ind[i] == pr[i]) {
      swap(pr[i], pr[i + 1]);
    }
  }
  if (ind[s - 1] == pr[s - 1]) {
    swap(pr[s - 1], pr[s - 2]);
  }
  for (int i = 0; i < s; i++) {
    f[ind[i]] = pr[i];
  }
  for (int i = 1; i <= n; i++) {
    cout << f[i];
    if (i == n) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
  return 0;
}
