#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, a[N], b[N], num[N];
stack<int> s1, s2;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    num[a[i]] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (num[i] == 0) s1.push(i);
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0) {
      b[i] = s1.top();
      s1.pop();
    }
  }
  for (int i = 1; i <= n; i++) {
    if (b[i] == i) {
      s2.push(i);
      b[i] = 0;
    }
  }
  while (s2.empty() != true) {
    int x = s2.top();
    s2.pop();
    for (int i = 1; i <= n; i++) {
      if (b[i] != 0 && b[i] != x && i != x) {
        b[x] = b[i];
        b[i] = x;
        break;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] != 0)
      printf("%d ", a[i]);
    else
      printf("%d ", b[i]);
  }
  return 0;
}
