//https://ncode.syosetu.com/n4830bu/241/ #include "atcoder/all" using namespace atcoder; #include using namespace std; int main() { int N; cin >> N; vector A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } mf_graph maine(N * 2 + 2); int s = N * 2, t = N * 2 + 1; for (int i = 0; i < N; i++) { maine.add_edge(s, i, 1); maine.add_edge(i + N, t, 1); for (int j = 0; j < N; j++) { if (j != A[i]) maine.add_edge(i, j + N, 1); } } if (maine.flow(s, t) == N) { vector ans(N); for (auto&& edge : maine.edges()) { if (edge.from < N && edge.flow == 1) ans[edge.from] = edge.to - N; } for (auto&& x : ans) { cout << x << endl; } } else cout << -1 << endl; }