import std.experimental.all; T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } alias readint = read!int; alias readints = reads!int; void maxBipartiteMatching(bool[][] g) { bool mbm(int p, int[] left, int[] right, bool[][] g, bool[] used) { for (int i = 0; i < right.length; i++) { if (g[p][i] && right[i] == -1) { left[p] = i; right[i] = p; return true; } } for (int i = 0; i < right.length; i++) { if (g[p][i] && !used[i]) { used[i] = true; if (mbm(right[i], left, right, g, used)) { left[p] = i; right[i] = p; return true; } } } return false; } auto left = new int[g.length]; auto right = new int[g[0].length]; left[] = -1; right[] = -1; int cnt = 0; for (int i = 0; i < left.length; i++) { auto used = new bool[left.length]; if (mbm(i, left, right, g, used)) { cnt++; } } if (cnt == left.length) { foreach (x; left) { writeln(x); } } else writeln(-1); } void main() { int n = readint; int[] a; for (int i = 0; i < n; i++) { a ~= readint; } auto g = new bool[][](n, n); for (int i = 0; i < n; i++) { g[i][] = true; g[i][a[i]] = false; } maxBipartiteMatching(g); }