#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long int llINF = 0x3f3f3f3f3f3f3f;
const int N = 2e5 + 10;
int a[N], used[N];
vector<int> rec, give;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    used[a[i]] = 1;
    if (a[i] == 0) {
      give.push_back(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!used[i]) rec.push_back(i);
  }
  for (int i = 0; i < (int)give.size(); i++) {
    if (give[i] == rec[i]) {
      if (i == 0) {
        swap(give[i], give[i + 1]);
      } else
        swap(give[i], give[i - 1]);
    }
  }
  for (int i = 0; i < give.size(); i++) {
    a[give[i]] = rec[i];
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << " \n"[i == n];
  }
}
