#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int T = 1;
  while (T--) {
    long long n;
    cin >> n;
    vector<int> a(n + 1);
    vector<bool> vis1(n + 1);
    vector<bool> vis2(n + 1);
    vector<int> ans(n + 1);
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      if (a[i] != 0) {
        vis1[i] = true;
        ans[i] = a[i];
      }
      vis2[a[i]] = true;
    }
    vector<int> bv, sv;
    for (int i = 1; i <= n; i++) {
      if (!vis1[i] && !vis2[i]) {
        bv.push_back(i);
      } else if (!vis2[i]) {
        sv.push_back(i);
      }
    }
    if (bv.size() == 1) {
      ans[bv[0]] = sv[0];
      sv[0] = bv[0];
    } else if (bv.size()) {
      for (int i = 0; i < bv.size() - 1; i++) {
        ans[bv[i]] = bv[i + 1];
      }
      ans[bv[bv.size() - 1]] = bv[0];
    }
    int k = 0;
    for (int i = 1; i <= n; i++) {
      if (ans[i] == 0) {
        ans[i] = sv[k];
        k++;
      }
    }
    for (int i = 1; i <= n; i++) {
      cout << ans[i] << " ";
    }
  }
}
