#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(x, to) for (int x = 0; x < (to); x++) #define REP(x, a, to) for (int x = (a); x < (to); x++) #define foreach(itr, x) for (typeof((x).begin()) itr = (x).begin(); itr != (x).end(); itr++) #define EPS (1e-14) using namespace std; typedef long long ll; typedef pair PII; typedef pair PLL; typedef complex Complex; typedef vector< vector > Mat; int N; int a[55]; struct Edge { int to; int cap; int rev; }; class Graph { public: vector < vector > G; vector level; vector iter; Graph(int n) { G.resize(n + 5); level.resize(n + 5, 0); iter.resize(n + 5, 0); } void add_edge(int from, int to, int cap) { G[from].push_back((Edge){to, cap, G[to].size()}); G[to].push_back((Edge){from, 0, G[from].size() - 1}); } //s:source int bfs(int s) { for (int i = 0; i < level.size(); i++) level[i] = -1; queue que; level[s] = 0; que.push(s); while (!que.empty()) { int v = que.front(); que.pop(); for (int i = 0; i < G[v].size(); i++) { Edge &e = G[v][i]; if (e.cap > 0 && level[e.to] < 0) { level[e.to] = level[v] + 1; que.push(e.to); } } } } //t:sink int dfs(int v, int t, int f) { if (v == t) return f; for (int &i = iter[v]; i < G[v].size(); i++) { Edge &e = G[v][i]; if (e.cap > 0 && level[v] < level[e.to]) { int d = dfs(e.to, t, min(f, e.cap)); if (d > 0) { e.cap -= d; G[e.to][e.rev].cap += d; return d; } } } return 0; } //s:source //t:sink int max_flow(int s, int t) { int flow = 0; for (;;) { bfs(s); if (level[t] < 0) return flow; for (int i = 0; i < iter.size(); i++) iter[i] = 0; int f; while (f = dfs(s, t, 1e+9 + 7)) { flow += f; } } } }; void solve() { Graph graph(105); int S = N + N; int T = N + N + 1; //u -> v; rep(i, N) { rep(j, N) { if (j == a[i]) continue; graph.add_edge(i, j + N, 1); } } //S -> u; v -> T; rep(i, N) { graph.add_edge(S, i, 1); graph.add_edge(i + N, T, 1); } int flow = graph.max_flow(S, T); if (flow != N) { cout << -1 << endl; } else { rep(i, N) { rep(j, graph.G[i].size()) { Edge &e = graph.G[i][j]; if (graph.G[e.to][e.rev].cap > 0) { cout << e.to - N << endl; break; } } } } } int main() { cin >> N; rep(i, N) cin >> a[i]; solve(); return 0; }