#include #define int long long #define endl '\n' #define FOR(i, a, n) for (int i = (a); i < (n); ++i) #define REP(i, n) FOR(i, 0, n) using namespace std; class HopcroftKarp { void bfs() { const int n = g.size(); dist.assign(n, -1); queue que; for (int i = 0; i < n; ++i) if (!used[i]) { que.push(i); dist[i] = 0; } while (!que.empty()) { int v = que.front(); que.pop(); for (int& u : g[v]) { int w = match[u]; if (w >= 0 && dist[w] == -1) { dist[w] = dist[v] + 1; que.emplace(w); } } } } bool dfs(int v) { vv[v] = true; for (auto& u : g[v]) { int w = match[u]; if (w < 0 || (!vv[w] && dist[w] == dist[v] + 1 && dfs(w))) { match[u] = v; used[v] = true; return true; } } return false; } public: vector> g; vector dist, match; vector used, vv; HopcroftKarp(int n, int m) : g(n), match(m, -1), used(n) {} void add_edge(int u, int v) { g[u].push_back(v); } int bipartite_matching() { const int n = g.size(); int res = 0; while (true) { bfs(); vv.assign(n, false); int flow = 0; for (int i = 0; i < n; ++i) { if (!used[i] && dfs(i)) ++flow; } if (!flow) break; res += flow; } return res; } void print() { for (int i = 0; i < match.size(); ++i) { if (~match[i]) cout << match[i] << " - " << i << endl; } } }; int N; int A[50]; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> N; HopcroftKarp g(N, N); REP (i, N) { cin >> A[i]; REP (j, N) if (j != A[i]) { g.add_edge(i, j); } } if (g.bipartite_matching() < N) { cout << -1 << endl; return 0; } REP (i, N) cout << g.match[i] << endl; }