#include <bits/stdc++.h>   using namespace std;   void quickly_quickly_kro() {     long long n;     cin >> n;     vector<long long> v(n);     for (long long i = 0; i < n; i++) cin >> v[i];     ;     map<long long, long long> M, N, I;     for (long long i = 0; i < n; i++) {       if (v[i] != 0)         M[v[i]]++;       else         I[i]++;     }     for (long long i = 1; i < n + 1; i++) {       if (M[i] == 0) {         N[i]++;       }     }     for (auto k : I) {       if ((N.find(k.first + 1) != N.end())) {         auto it = N.find(k.first + 1);         if (it != N.begin())           it--;         else           it++;         v[k.first] = it->first;         N.erase(it);       }     }     for (long long i = 0; i < n; i++) {       if (v[i] == 0) {         auto it = N.begin();         pair<long long, long long> p = *it;         v[i] = p.first;         N.erase(it);       }     }     for (long long i = 0; i < n; i++) cout << v[i] <<    ;   }   signed main() {     std::ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t;     t = 1;     while (t--) {       quickly_quickly_kro();       cout <<   n ;       ;     }     return 0;   }   