#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; constexpr int INF = 1001001001; constexpr int mod = 1000000007; // constexpr int mod = 998244353; template inline bool chmax(T& x, T y){ if(x < y){ x = y; return true; } return false; } template inline bool chmin(T& x, T y){ if(x > y){ x = y; return true; } return false; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector A(N); for(int i = 0; i < N; ++i) cin >> A[i]; if(N == 1){ cout << -1 << endl; return 0; } bool ng = true; for(int i = 0; i + 1 < N; ++i){ if(A[i] != A[i + 1]) ng = false; } if(ng){ cout << -1 << endl; return 0; } vector S(N); for(int i = 0; i < N; ++i) S[i] = i; bool update = true; int counter = 0; while(update){ assert(++counter <= 100000); update = false; for(int i = 0; i < N; ++i){ if(S[i] == A[i]){ for(int j = 0; j < N; ++j){ if(i == j) continue; if(S[j] != A[i] && S[i] != A[j]){ swap(S[i], S[j]); update = true; break; } } break; } } } for(int i = 0; i < N; ++i) cout << S[i] << '\n'; return 0; }