#include <bits/stdc++.h>
const double pi = acos(-1.0);
const int maxn = (2e5 + 10);
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
using namespace std;
bool cd[maxn], rd[maxn];
queue<int> q;
int a[maxn];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    a[i] = x;
    if (x != 0) {
      cd[i] = true;
      rd[x] = true;
    }
  }
  for (int i = 1; i <= n; i++)
    if (rd[i] == false) q.push(i);
  for (int i = 1; i <= n; i++)
    if (rd[i] == false && cd[i] == false) {
      if (q.front() != i) {
        a[i] = q.front();
        q.pop();
      } else {
        q.push(q.front());
        q.pop();
        a[i] = q.front();
        q.pop();
      }
    }
  for (int i = 1; i <= n; i++)
    if (a[i] == 0) {
      a[i] = q.front();
      q.pop();
    }
  for (int i = 1; i <= n; i++) cout << a[i] << " ";
  return 0;
}
