#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n;
  cin >> n;
  set<long long> s;
  for (long long i = 1; i <= n; i++) {
    s.insert(i);
  }
  long long arr[n + 1];
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
    if (arr[i] != 0) {
      s.erase(arr[i]);
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (arr[i] == 0 && s.find(i) != s.end()) {
      s.erase(i);
      arr[i] = *(s.begin());
      s.erase(*(s.begin()));
      s.insert(i);
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (arr[i] == 0 && s.find(i) == s.end()) {
      arr[i] = *(s.begin());
      s.erase(*(s.begin()));
    }
  }
  for (long long i = 1; i <= n; i++) {
    cout << arr[i] << " ";
  }
  cout << endl;
  return 0;
}
