#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, c;
  cin >> n;
  int v[n + 1];
  set<int> s;
  for (int i = 1; i <= n; i++) s.insert(i);
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    if (v[i] != 0) s.erase(v[i]);
  }
  for (int i = 1; i <= n; i++)
    if (v[i] == 0)
      if (s.count(i) > 0) {
        c = *s.begin();
        if (c == i) c = *(--s.end());
        v[i] = c;
        s.erase(c);
      }
  for (int i = 1; i <= n; i++) {
    if (v[i] == 0) {
      c = *s.begin();
      cout << c << " ";
      s.erase(c);
    } else
      cout << v[i] << " ";
  }
  return 0;
}
