#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int f[200001];
  vector<int> notGifted;
  int checkGiven[200001] = {0};
  for (int i = 1; i <= n; i++) {
    cin >> f[i];
    checkGiven[f[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    if (checkGiven[i] == 0) {
      notGifted.push_back(i);
    }
  }
  int zero = notGifted.size();
  int j = 0;
  for (int i = 1; i <= n; i++) {
    if (f[i] == 0) {
      if (notGifted[j] == i) {
        int x = notGifted[j];
        notGifted[j] = notGifted[(j + 1) % zero];
        notGifted[(j + 1) % zero] = x;
      }
      j++;
    }
  }
  j = 0;
  for (int i = 1; i <= n; i++) {
    if (f[i] == 0) {
      f[i] = notGifted[j];
      j++;
    }
  }
  for (int i = 1; i <= n; i++) cout << f[i] << " ";
  return 0;
}
