#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  priority_queue<long long> pq;
  long long a[n + 3];
  map<long long, long long> mp;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    mp[a[i]] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (mp[i] == 0) pq.push(i);
  }
  long long f = -1;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0) {
      if (pq.top() != i) {
        a[i] = pq.top();
        pq.pop();
        if (f == -1) f = i;
      } else if (pq.top() == i && pq.size() == 1) {
        a[i] = a[f];
        a[f] = pq.top();
      } else {
        long long tm = pq.top();
        pq.pop();
        a[i] = pq.top();
        pq.pop();
        pq.push(tm);
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << a[i] << " ";
  cout << endl;
  return 0;
}
