#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
using namespace std;
void myfun() {
  long long n, i;
  cin >> n;
  set<long long> ss;
  for (i = 1; i <= n; i++) ss.insert(i);
  long long arr[n];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    ss.erase(arr[i]);
  }
  vector<long long> pos;
  for (i = 0; i < n; i++) {
    if (arr[i] == 0) {
      if (ss.find(i + 1) != ss.end()) {
        arr[i] = i + 1;
        ss.erase(i + 1);
        pos.push_back(i);
      }
    }
  }
  for (i = 0; i < n; i++) {
    if (arr[i] == 0) {
      arr[i] = *ss.begin();
      pos.push_back(i);
      ss.erase(*ss.begin());
    }
  }
  long long nn = pos.size();
  for (i = 0; i < nn - 1; i++) {
    swap(arr[pos[i]], arr[pos[i + 1]]);
  }
  for (i = 0; i < n; i++) cout << arr[i] << " ";
  cout << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) myfun();
  return 0;
}
