#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll loops")
using namespace std;
const long long int MOD = 1e9 + 7;
const long long int INF = 1e18;
bool isPrime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  long long int p = sqrt(n);
  for (int i = 5; i <= p; i += 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long int mod(long long int n) { return (n % MOD + MOD) % MOD; }
long long int fp(long long int a, long long int b) {
  if (b == 0) return 1;
  long long int t = fp(a, b / 2);
  if (b % 2 == 0)
    return mod(t * t);
  else
    return mod(mod(t * t) * a);
}
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 lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int gcdExtended(long long int a, long long int b, long long int* x,
                          long long int* y) {
  if (a == 0) {
    *x = 0, *y = 1;
    return b;
  }
  long long int x1, y1;
  long long int gcd = gcdExtended(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
long long int modInverse(long long int a, long long int m) {
  long long int x, y;
  long long int g = gcdExtended(a, m, &x, &y);
  long long int res = (x % m + m) % m;
  return res;
}
int kx[8] = {1, 2, 1, 2, -1, -2, -1, -2};
int ky[8] = {2, 1, -2, -1, 2, 1, -2, -1};
int dx[4] = {0, -1, 0, 1};
int dy[4] = {-1, 0, 1, 0};
vector<int> adj[200100];
int visited[1000][1000];
bool isvalid(long long int x, long long int y, long long int n,
             long long int m) {
  if (x >= 0 && y >= 0 && x < n && y < m && !visited[x][y]) return true;
  return false;
}
void bfs(long long int i, long long int j, vector<vector<char>> v,
         long long int n, long long int m) {
  queue<pair<long long int, long long int>> q;
  q.push({i, j});
  while (!q.empty()) {
    pair<long long int, long long int> temp = q.front();
    visited[temp.first][temp.second] = 1;
    long long int cur_x = temp.first;
    long long int cur_y = temp.second;
    for (int i = 0; i < 4; i++) {
      long long int new_x = cur_x + dx[i];
      long long int new_y = cur_y + dy[i];
      if (isvalid(new_x, new_y, n, m) && v[new_x][new_y] == '.') {
        visited[new_x][new_y] = 1;
        q.push({new_x, new_y});
      }
    }
  }
  return;
}
long long int color[200100] = {0};
bool vis[100000 + 5];
long long int dp[2][100000 + 5];
long long int tot[100000 + 5];
void dfs(long long int cur, long long int par) {}
bool valid(string s, string sub, int j) {
  for (int i = 0; i < sub.length(); i++, j++)
    if (s[j] != sub[i]) return false;
  return true;
}
bool c1(pair<long long int, long long int> a,
        pair<long long int, long long int> b) {
  if (a.first <= b.first)
    return 1;
  else
    return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  t = 1;
  while (t--) {
    long long int n;
    cin >> n;
    vector<long long int> v(n);
    map<long long int, long long int> m;
    for (long long int i = 1; i < n + 1; i++) m[i]++;
    for (long long int i = 0; i < n; i++) {
      cin >> v[i];
      if (v[i] != 0) m.erase(v[i]);
    }
    list<long long int> ls;
    for (long long int i = 0; i < n; i++) {
      if (v[i] == 0 && m.find(i + 1) != m.end()) {
        ls.push_back(i + 1);
      } else if (v[i] == 0)
        ls.push_front(i + 1);
    }
    for (auto it = ls.rbegin(); it != ls.rend(); it++) {
      auto i = m.begin();
      for (i; i != m.end(); i++) {
        if (*it != i->first) {
          v[*it - 1] = i->first;
          break;
        }
      }
      m.erase(i->first);
    }
    for (long long int i = 0; i < n; i++) cout << v[i] << " ";
  }
  return 0;
}
