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; alias MatchResult = Tuple!(int, "count", int[], "left", int[], "right"); MatchResult maxBipartiteMatching(bool[][] g) { bool rec(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 (rec(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 (rec(i, left, right, g, used)) { cnt++; } } return MatchResult(cnt, left, right); } 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; } auto result = maxBipartiteMatching(g); if (result.count == result.left.length) { foreach (x; result.left) writeln(x); } else writeln(-1); }