#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> arr(n);
  vector<int> vis(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] != 0) vis[arr[i] - 1]++;
  }
  vector<int> pos;
  for (int i = 0; i < n; i++) {
    if (arr[i] == 0) {
      pos.push_back(i);
    }
  }
  vector<int> miss_nos;
  for (int i = 0; i < n; i++) {
    if (vis[i] == 0) {
      miss_nos.push_back(i + 1);
    }
  }
  int len = pos.size();
  for (int i = 0; i < len; i++) {
    arr[pos[i]] = miss_nos[i];
  }
  for (int i = 0; i < len - 1; i++) {
    if (arr[pos[i]] == pos[i] + 1 || arr[pos[i + 1]] == pos[i + 1] + 1) {
      int temp = arr[pos[i]];
      arr[pos[i]] = arr[pos[i + 1]];
      arr[pos[i + 1]] = temp;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << arr[i] << " ";
  }
  cout << endl;
  return;
}
int main() {
  int t;
  t = 1;
  while (t--) {
    solve();
  }
}
