#include <bits/stdc++.h>
using namespace std;
int a[200005], vis[200005], c[200005], d[200005];
int main() {
  int n, cnt2 = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    vis[a[i]] = 1;
    if (a[i] == 0) {
      cnt2++;
      d[cnt2] = i;
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      cnt++;
      c[cnt] = i;
    }
  }
  sort(c + 1, c + 1 + cnt);
  sort(d + 1, d + 1 + cnt);
  for (int i = 1; i <= cnt; i++) {
    if (c[i] == d[i] && i < cnt) {
      swap(c[i], c[i + 1]);
      a[d[i]] = c[i];
    } else if (c[i] == d[i] && i == cnt) {
      swap(c[i], c[i - 1]);
      a[d[i]] = c[i];
      a[d[i - 1]] = c[i - 1];
    } else {
      a[d[i]] = c[i];
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i != n)
      printf("%d ", a[i]);
    else {
      printf("%d\n", a[i]);
    }
  }
}
