#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i;
  cin >> n;
  long long int arr[n + 1];
  long long int given[n + 1];
  set<long long int>::iterator it1, it2;
  memset(given, 0, sizeof(given));
  for (i = 1; i < n + 1; i++) {
    cin >> arr[i];
    if (arr[i] != 0) {
      given[arr[i]] = 1;
    }
  }
  set<long long int> notGiven;
  for (i = 1; i < n + 1; i++) {
    if (given[i] == 0) notGiven.insert(i);
  }
  set<long long int, greater<long long int>> se;
  for (i = 1; i < n + 1; i++) {
    if (arr[i] == 0 && notGiven.find(i) != notGiven.end()) {
      se.insert(i);
    }
  }
  it1 = se.begin();
  while (it1 != se.end()) {
    it2 = notGiven.begin();
    while (*it1 == *it2) {
      it2++;
    }
    arr[*it1] = *it2;
    it1++;
    notGiven.erase(*it2);
  }
  it1 = notGiven.begin();
  for (i = 1; i <= n; i++) {
    if (arr[i] == 0) {
      arr[i] = *it1;
      it1++;
    }
  }
  for (i = 1; i <= n; i++) {
    cout << arr[i] << " ";
  }
}
