#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  map<int, bool> mp;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]] = true;
  }
  deque<int> dq;
  for (int i = 1; i <= n; i++) {
    if (!mp[i]) dq.push_front(i);
  }
  int z = 0;
  for (int i = 0; i < n; i++) {
    if (a[i])
      continue;
    else {
      if (dq.front() == i + 1) {
        if (dq.size() > 1) {
          dq.push_back(dq.front());
          dq.pop_front();
          a[i] = dq.front();
          dq.pop_front();
        } else {
          a[i] = dq.front();
          swap(a[i], a[z]);
          dq.pop_front();
        }
      } else {
        a[i] = dq.front();
        z = i;
        dq.pop_front();
      }
    }
  }
  for (int i = 0; i < n; i++) cout << a[i] << " ";
}
