#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, i;
  cin >> n;
  int arr[n + 5];
  vector<int> v;
  map<int, int> mp;
  for (i = 1; i <= n; i++) {
    cin >> arr[i];
    if (arr[i] == 0)
      v.push_back(i);
    else
      mp[arr[i]]++;
  }
  set<int> second;
  for (i = 1; i <= n; i++) {
    if (mp[i] == 0) second.insert(i);
  }
  vector<int> same, opp;
  for (i = 0; i < v.size(); i++) {
    if (second.find(v[i]) != second.end()) {
      same.push_back(v[i]);
      second.erase(v[i]);
    } else
      opp.push_back(v[i]);
  }
  int ind = 0;
  for (auto x : second) arr[opp[ind++]] = x;
  for (i = 0; i < same.size(); i++)
    arr[same[i]] = same[(i + 1) % ((int)same.size())];
  if (same.size() == 1) swap(arr[same[0]], arr[opp[0]]);
  for (i = 1; i <= n; i++) cout << arr[i] << ' ';
}
