#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> vec(200007, 0), got(200007, 0), gave(200007, 0);
  deque<int> haventGot, haventGave, Nerd;
  for (int i = 1; i <= n; i++) {
    cin >> vec[i];
    got[vec[i]] = i;
    gave[i] = vec[i];
  }
  for (int i = 1; i <= n; i++) {
    if (got[i] == 0 && gave[i] == 0)
      Nerd.push_back(i);
    else if (gave[i] == 0)
      haventGave.push_back(i);
    if (got[i] == 0) haventGot.push_back(i);
  }
  while (!Nerd.empty()) {
    if (haventGot.front() == Nerd.front()) {
      int temp = haventGot.front();
      haventGot.pop_front();
      haventGot.push_back(temp);
    }
    vec[Nerd.front()] = haventGot.front();
    Nerd.pop_front();
    haventGot.pop_front();
  }
  while (!haventGave.empty()) {
    if (haventGot.front() == haventGave.front()) {
      int temp = haventGot.front();
      haventGot.pop_front();
      haventGot.push_back(temp);
    }
    vec[haventGave.front()] = haventGot.front();
    haventGave.pop_front();
    haventGot.pop_front();
  }
  for (int i = 1; i <= n; i++) {
    cout << vec[i] << " ";
  }
  cout << endl;
  return 0;
}
