#include <bits/stdc++.h>   using namespace std;   int a[200005];   bool got[200004], gave[200004];   queue<int> q;   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       got[a[i]] = 1;       if (a[i] != 0) {         gave[i] = 1;       }     }     for (int i = 1; i <= n; i++) {       if (!got[i]) {         q.push(i);       }     }     for (int i = 1; i <= n; i++) {       if (!got[i] && !gave[i]) {         int x = q.front();         q.pop();         if (x == i) {           q.push(x);           x = q.front();           q.pop();         }         a[i] = x;         gave[i] = 1;         got[x] = 1;       }     }     for (int i = 1; i <= n; i++) {       if (!gave[i]) {         int x = q.front();         q.pop();         a[i] = x;         gave[i] = 1;         got[x] = 1;       }     }     for (int i = 0; i < n; i++) {       cout << a[i + 1] <<    ;     }     return 0;   }   