#include "bits/stdc++.h" using namespace std; #define REP(i, n) for(int i=0; i<(n); i++) int N; int ok(vector A, vector B) { REP(i,N) { if (B[i] == A[i]) return i; } return -1; } signed main() { cin >> N; vector A(N); vector B(N); REP(i,N) cin >> A[i]; REP(i,N) B[i] = i; int t; int cnt = 0; while((t = ok(A, B)) > -1) { int hate = B[t]; // この番号をほかの人に移したい REP(i,N) { if (A[i] != hate) { swap(B[i], B[t]); break; } } if (cnt++ > 100) break; } if (t != -1) { cout << -1 << endl; return 0; } REP(i,N) cout << B[i] << endl; return 0; }