#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const long long MAX = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int a[n];
  set<int> s;
  for (int i = 0; i < n; i++) s.insert(i + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i]) s.erase(a[i]);
  }
  int prev = -1;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      auto it = s.begin();
      while (it != s.end() && *it == (i + 1)) it++;
      if (it == s.end()) {
        it = s.begin();
        a[i] = a[prev];
        a[prev] = *it;
      } else {
        a[i] = *it;
        s.erase(it);
        prev = i;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << "\n";
  return 0;
}
