#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
const long long int MOD = 1e18 + 7;
const long long int INF = 3e18;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int powm(long long int a, long long int b) {
  long long int res = 1;
  while (b) {
    if (b & 1) res = (res * 1LL * a) % mod;
    b >>= 1LL;
    a = (a * 1LL * a) % mod;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int a[n + 1];
  set<int> s;
  vector<bool> g(n + 1, 0);
  vector<bool> z(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    g[a[i]] = 1;
    if (a[i] == 0) z[i] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (!g[i]) {
      s.insert(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (z[i]) {
      if (s.find(i) != s.end()) {
        for (auto j : s) {
          if (i != j) {
            a[i] = j;
            s.erase(j);
            z[i] = 0;
            break;
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (z[i]) {
      for (auto j : s) {
        if (i != j) {
          a[i] = j;
          s.erase(j);
          z[i] = 0;
          break;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i];
    cout << " ";
  }
  return 0;
}
