#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  long long int x, n;
  std::cin >> n;
  set<long long int> a, b;
  vector<long long int> ans(n);
  for (long long int i = 0; i < n; i++) b.insert(i + 1);
  for (long long int i = 0; i < n; i++) {
    std::cin >> x;
    if (x == 0)
      a.insert(i + 1);
    else
      ans[i] = x, b.erase(x);
  }
  for (auto itr = a.begin(); itr != a.end();) {
    if (b.find(*itr) != b.end()) {
      auto i = b.begin();
      if (*i == *itr) i++;
      ans[*itr - 1] = *i;
      auto o = itr;
      itr++;
      a.erase(o), b.erase(i);
    } else
      itr++;
  }
  for (auto itr = a.begin(); itr != a.end();) {
    auto i = b.begin();
    ans[*itr - 1] = *i;
    auto o = itr;
    itr++;
    a.erase(o), b.erase(i);
  }
  for (long long int i = 0; i < n; i++)
    std::cout << ans[i] << (i == n - 1 ? "\n" : " ");
  return 0;
}
