#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n], b[n + 1];
  vector<int> v, a;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] == 0) a.push_back(i + 1);
  }
  for (int i = 0; i <= n; i++) b[i] = 0;
  for (int i = 0; i < n; i++) {
    b[arr[i]]++;
  }
  for (int i = 0; i <= n; i++) {
    if (b[i] == 0) v.push_back(i);
  }
  for (int i = 0; i < v.size(); i++) {
    if (a[i] == v[i]) {
      if (i == v.size() - 1)
        swap(v[v.size() - 1], v[0]);
      else
        swap(v[i], v[i + 1]);
    }
  }
  int k = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] == 0) {
      arr[i] = v[k];
      k++;
    }
    cout << arr[i] << " ";
  }
}
