#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
const int N = 2e5 + 314;
void foo() {
  int n;
  cin >> n;
  vector<int> v(n), t(n), k(n);
  set<int> s1, s2;
  map<int, int> make_pair;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    s1.insert(i + 1);
    s2.insert(i + 1);
  }
  for (int i = 0; i < n; i++) {
    if (v[i] != 0) {
      s1.erase(v[i]);
      s2.erase(v[i]);
    }
  }
  for (int i = 0; i < n; i++) {
    if (!v[i]) {
      if (i + 1 == *s1.rbegin()) {
        t[i] = *s1.begin();
        s1.erase(*s1.begin());
      } else {
        t[i] = *s1.rbegin();
        s1.erase(*s1.rbegin());
      }
    } else
      t[i] = v[i];
  }
  for (int i = 0; i < n; i++) {
    if (!v[i]) {
      if (i + 1 == *s2.begin()) {
        k[i] = *s2.rbegin();
        s2.erase(*s2.rbegin());
      } else {
        k[i] = *s2.begin();
        s2.erase(*s2.begin());
      }
    } else
      k[i] = v[i];
  }
  bool q = true, w = true;
  for (int i = 0; i < n; i++) {
    if (t[i] == i + 1) {
      q = false;
      break;
    }
    if (k[i] == i + 1) {
      w = false;
      break;
    }
  }
  if (q) {
    for (int i = 0; i < n; i++) cout << t[i] << " ";
  } else
    for (int i = 0; i < n; i++) cout << k[i] << " ";
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) foo();
}
