#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
int main() {
  int n;
  cin >> n;
  int arr[n];
  vector<int> zz, vt;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] == 0)
      zz.push_back(i);
    else
      mp[arr[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    if (mp.find(i) == mp.end()) vt.push_back(i);
  }
  int len = vt.size();
  for (int i = 0; i < len; i++) {
    if (zz[i] + 1 == vt[i]) {
      int a = (i + 1) % len;
      swap(vt[i], vt[a]);
    }
  }
  for (int i = 0; i < len; i++) {
    arr[zz[i]] = vt[i];
  }
  for (int i = 0; i < n; i++) cout << arr[i] << " ";
  cout << '\n';
  return 0;
}
