#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
const long long MOD = 1e9 + 7;
const int INF = (1 << 23);
const int LINF = (1ULL << 56);
int main() {
  int n;
  scanf("%d", &n);
  int a[n + 5];
  bool done[n + 5];
  for (int i = 1; i <= n; i++) done[i] = false;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    done[a[i]] = true;
  }
  vector<int> nd;
  for (int i = 1; i <= n; i++)
    if (!done[i]) nd.push_back(i);
  int fp = 0;
  int lp = nd.size() - 1;
  vector<int> ans(n + 5);
  fill(ans.begin(), ans.end(), -1);
  for (int i = 1; i <= n; i++) {
    if (!done[i] && a[i] == 0) {
      if (nd[fp] == i) {
        ans[i] = nd[lp];
        lp--;
      } else {
        ans[i] = nd[fp];
        fp++;
      }
    } else if (a[i] != 0) {
      ans[i] = a[i];
    }
  }
  for (int i = 1; i <= n; i++) {
    if (ans[i] == -1) {
      ans[i] = nd[fp];
      fp++;
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
