#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> v(n), ind;
  set<long long> rem;
  deque<long long> dq;
  for (int i = 1; i <= n; i++) rem.insert(i);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] == 0)
      ind.push_back(i);
    else
      rem.erase(rem.find(v[i]));
  }
  for (auto x : rem) dq.push_back(x);
  int last = ind.back();
  ind.pop_back();
  for (auto i : ind) {
    if (dq.front() == i + 1) {
      int temp = dq.front();
      dq.pop_front();
      v[i] = dq.front();
      dq.pop_front();
      dq.push_front(temp);
    } else {
      v[i] = dq.front();
      dq.pop_front();
    }
  }
  v[last] = dq.front();
  if (v[last] == last + 1) {
    swap(v[last], v[ind[0]]);
  }
  for (auto x : v) cout << x << " ";
}
