#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), in(n), out(n), free;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    --a[i];
    if (a[i] != -1) {
      in[a[i]]++;
      out[i]++;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (out[i] == 0 && in[i] == 0) {
      free.push_back(i);
    }
  }
  if ((int)free.size() == 1) {
    int pos = free[0];
    for (int i = 0; i < n; ++i) {
      if (!in[i] && i != pos) {
        a[pos] = i;
        in[i]++;
        out[pos]++;
        break;
      }
    }
  } else if ((int)free.size() > 1) {
    for (int i = 0; i < (int)free.size(); ++i) {
      int next = free[(i + 1) % (int)free.size()];
      out[free[i]]++;
      in[next]++;
      a[free[i]] = next;
    }
  }
  vector<int> ins, outs;
  for (int i = 0; i < n; ++i) {
    if (!in[i]) ins.push_back(i);
    if (!out[i]) outs.push_back(i);
  }
  for (int i = 0; i < (int)outs.size(); ++i) {
    a[outs[i]] = ins[i];
  }
  for (int i = 0; i < n; ++i) {
    cout << a[i] + 1 << ' ';
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
}
