#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using pll = pair<ll, ll>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
using namespace std;
int main() {
  cin.sync_with_stdio(0);
  ll n;
  cin >> n;
  vector<ll> input(n);
  vector<ll> free;
  vector<ll> toMove;
  set<ll> pre;
  for (ll i = (0); i < (n); i++) {
    cin >> input[i];
    if (input[i] != 0) pre.insert(input[i]);
  }
  set<ll> missing;
  for (ll i = (1); i < (n + 1); i++) {
    if (pre.find(i) == pre.end()) missing.insert(i);
  }
  vector<ll> output(n);
  vector<ll> prob;
  for (ll i = (0); i < (n); i++) {
    if (input[i] != 0)
      output[i] = input[i];
    else {
      ll curr = *missing.begin();
      if (curr == i + 1) {
        prob.push_back(curr);
      }
      output[i] = curr;
      missing.erase(curr);
    }
  }
  if (ll((prob).size()) == 1) {
    for (ll i = (0); i < (n); i++) {
      if (input[i] == 0 && output[i] != prob[0]) {
        swap(output[i], output[prob[0] - 1]);
        break;
      }
    }
  } else {
    ll probI = 0;
    for (ll i = (0); i < (n); i++) {
      if (output[i] == i + 1) {
        output[i] = prob[(probI + 1) % ll((prob).size())];
        probI++;
      }
    }
  }
  for (ll i = (0); i < (n); i++) {
    cout << output[i];
    if (i != n - 1) cout << " ";
  }
  cout << endl;
}
