#include <bits/stdc++.h>
using namespace std;
void ans() {
  long long n;
  cin >> n;
  long long a[n], i = 0;
  map<long long, long long> ma;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    ma[i + 1]++;
  }
  for (i = 0; i < n; i++) {
    if (a[i] != 0) ma[a[i]]--;
  }
  long long ans = 0, x = 0;
  int siz = 0;
  i = 0;
  long long minu = 0, pre = -1;
  int j = 0;
  vector<int> v;
  for (auto i : ma) {
    if (i.second == 1) {
      v.push_back(i.first);
      siz++;
    }
  }
  sort(v.begin(), v.end(), greater<int>());
  i = 0;
  int h = 0;
  j = 0;
  while (j < n) {
    if ((j + 1) < v[h] && a[j] != 0) {
      j++;
    } else if ((j + 1) != v[h] && a[j] == 0) {
      j++;
      h++;
    } else if ((j + 1) == v[h] && a[j] == 0) {
      if (h > 0) {
        swap(v[h - 1], v[h]);
      } else if (h < siz - 1) {
        swap(v[h], v[h + 1]);
      }
      h++;
      j++;
    } else if ((j + 1) == v[h] && a[j] != 0) {
      j++;
      h++;
    } else {
      h++;
      j++;
    }
    if (h == siz) {
      break;
    }
  }
  h = 0;
  j = 0;
  while (j < n) {
    if (a[j] == 0) {
      a[j] = v[h];
      h++;
    }
    j++;
  }
  for (i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  while (t--) {
    ans();
  }
  return 0;
}
