#include <bits/stdc++.h>
using namespace std;
int n;
int a[222222];
set<int> s;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    s.insert(i);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] != 0) {
      s.erase(a[i]);
    }
  }
  int idx = n;
  int iidx = 0;
  int iiidx = -1;
  for (auto &x : s) {
    while (a[idx] != 0) {
      idx--;
    }
    a[idx] = x;
    iidx = idx;
    if (iiidx == -1) {
      iiidx = idx;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == i) {
      if (i == iidx) {
        a[i] = a[iiidx];
        a[iiidx] = i;
      } else {
        a[i] = a[iidx];
        a[iidx] = i;
      }
      break;
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", a[i]);
  }
  return 0;
}
