#include <bits/stdc++.h>
using namespace std;
int a[200033], b[200002];
int vis[200003] = {0};
int x[200003];
int main() {
  int n;
  scanf("%d", &n);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] != 0) {
      vis[a[i]] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      b[cnt++] = i;
    }
  }
  int ans = 0;
  cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0) {
      x[cnt++] = i;
      a[i] = b[ans++];
    }
  }
  ans = 0;
  int y = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] == i) {
      while (a[i] == x[ans]) {
        ans++;
        if (ans == cnt) {
          ans = 0;
        }
      }
      swap(a[i], a[x[ans]]);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i != 1) printf(" ");
    printf("%d", a[i]);
  }
  return 0;
}
