#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}
template <typename F, typename S>
ostream &operator<<(ostream &os, const pair<F, S> &p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename first, typename second>
ostream &operator<<(ostream &os, const map<first, second> &v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << it->first << " = " << it->second;
  }
  return os << "]";
}
const long long MOD = 1000000007;
const long long N = 100000;
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while (!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) long long idx,
               __attribute__((unused)) long long LINE_NUM) {
  cerr << "\n";
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, long long idx, long long LINE_NUM, Head H,
               Tail... T) {
  if (idx > 0)
    cerr << ", ";
  else
    cerr << "Line(" << LINE_NUM << ") =  ";
  stringstream ss;
  ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  set<long long, greater<long long>> s;
  map<long long, long long> does;
  for (long long i = 0; i < n; i++) {
    s.insert(i + 1);
  }
  map<long long, long long> rec;
  for (long long i = 0; i < n; i++) {
    if (a[i] != 0) {
      s.erase(a[i]);
      rec[a[i]] = true;
    } else {
      does[i] = 1;
    }
  }
  vector<long long> b(s.begin(), s.end());
  long long pt = 0;
  for (long long i = 0; i < n; i++) {
    if (a[i] == 0) {
      if (b[pt] == i + 1) {
        if (pt - 1 >= 0)
          swap(b[pt], b[pt - 1]);
        else
          swap(b[pt], b[pt + 1]);
      }
      pt++;
    }
  }
  pt = 0;
  for (long long i = 0; i < n; i++) {
    if (a[i] == 0) {
      a[i] = b[pt];
      pt++;
    }
  }
  for (auto t : a) cout << t << " ";
  cout << '\n';
  return 0;
}
