#include <bits/stdc++.h>
using namespace std;
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  vector<int> in(n + 1, 0), out(n + 1, 0), result(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> result[i];
    if (result[i]) {
      out[i]++;
      in[result[i]]++;
    }
  }
  vector<int> left;
  for (int i = 1; i <= n; i++) {
    if (in[i] == 0 and out[i] == 0) {
      left.push_back(i);
    }
  }
  int l = left.size();
  if (l > 1) {
    for (int i = 0; i < l; i++) {
      out[left[i]]++;
      in[left[(i + 1) % l]]++;
      result[left[i]] = left[(i + 1) % l];
    }
  } else if (l == 1) {
    for (int j = 1; j <= n; j++) {
      if (left[0] != j) {
        if (in[j] == 0) {
          out[left[0]]++;
          in[j]++;
          result[left[0]] = j;
          break;
        }
      }
    }
  }
  vector<int> start, end;
  for (int i = 1; i <= n; i++) {
    if (out[i] == 0) {
      start.push_back(i);
    }
    if (in[i] == 0) {
      end.push_back(i);
    }
  }
  while (!start.empty()) {
    result[start.back()] = end.back();
    start.pop_back();
    end.pop_back();
  }
  for (int i = 1; i <= n; i++) {
    cout << result[i] << " ";
  }
}
