#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const long long inf = 1e9 + 7;
long long mod = 998244353;
int n, a[maxn], vis[maxn];
int main(void) {
  scanf("%d", &n);
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    vis[a[i]] = 1;
  }
  queue<int> q, q1;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      q.push(i);
      if (a[i] == 0) q1.push(i);
    }
  }
  while (!q1.empty()) {
    int tmp = q1.front();
    q1.pop();
    int t = q.front();
    q.pop();
    if (tmp != t)
      a[tmp] = t;
    else {
      q.push(t);
      t = q.front();
      q.pop();
      a[tmp] = t;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0) {
      int t = q.front();
      q.pop();
      if (t != i)
        a[i] = t;
      else {
        q.push(t);
        t = q.front();
        q.pop();
        a[i] = t;
      }
    }
  }
  for (int i = 1; i <= n; i++) printf("%d%c", a[i], i == n ? '\n' : ' ');
  return 0;
}
