#include #define int long long using namespace std; const int INF = INT64_MAX/3, modl=1e9+7, MAXN = 2e5, MXN = 2e3; mt19937 gen(chrono::steady_clock::now().time_since_epoch().count()); int check( vector &arr, vector &pd ) { int n = arr.size(); for( int i = 0 ; i < n ; i++ ) { if( arr[i] == pd[i] ) return 0; } return 1; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, T = 5e7/500, f = 1; cin >> n; vector arr, pd(n); for( int i=0 ; i < n ; i++ ) cin >> pd[i], arr.push_back(i); for( ; T-- ; ) { shuffle(arr.begin(), arr.end(), gen); if( check(arr, pd) ) { for( int i : arr ) cout << i << '\n'; return 0; } } cout << -1 << '\n'; }