#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
vector<bool> mark(maxn);
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> g;
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    a--;
    g.push_back(a);
    if (a >= 0) mark[a] = true;
    ans.push_back(a);
  }
  priority_queue<int, vector<int>, greater<int>> pq;
  for (int i = 0; i < n; i++) {
    if (mark[i] == false) pq.push(i);
  }
  int sol = -1;
  for (int i = 0; i < n; i++) {
    if (g[i] != -1) continue;
    int topo = pq.top();
    pq.pop();
    if (topo != i) {
      g[i] = topo;
      mark[topo] = true;
      continue;
    }
    int topoa;
    if (pq.size() >= 1) {
      topoa = pq.top();
      pq.pop();
      pq.push(topo);
      g[i] = topoa;
      mark[topoa] = true;
      continue;
    }
    sol = i;
  }
  if (sol == -1) {
    for (int i = 0; i < n; i++) {
      cout << g[i] + 1 << " ";
    }
    cout << endl;
    return 0;
  }
  int troca;
  for (int i = 0; i < n; i++) {
    if (ans[i] == -1 && i != sol) {
      troca = i;
      break;
    }
  }
  g[sol] = g[troca];
  g[troca] = sol;
  for (int i = 0; i < n; i++) {
    cout << g[i] + 1 << " ";
  }
  cout << endl;
}
