#include using namespace std; class bipartite_matching { int n; vector > g; vector match; vector used; bool dfs(int v) { used[v] = true; for (int u: g[v]) { int w = match[u]; if (w < 0 || !used[w] && dfs(w)) { match[v] = u; match[u] = v; return true; } } return false; } public: bipartite_matching(int n) { this->n = n; this->g = vector >(n); this->match = vector(n, -1); this->used = vector(n); } void add_edge(int u, int v) { g[u].push_back(v); g[v].push_back(u); } int build() { int ret = 0; for (int v = 0; v < n; v++) { if (match[v] < 0) { fill(used.begin(), used.end(), false); if (dfs(v)) ++ret; } } return ret; } int pair(int v) { return match[v]; } }; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; bipartite_matching bm(2*n); for (int i = 0; i < n; i++) { int a; cin >> a; for (int j = 0; j < n; j++) { if (j != a) { bm.add_edge(i, n+j); } } } if (bm.build() != n) { cout << -1 << endl; } else { for (int i = 0; i < n; i++) cout << bm.pair(i) - n << endl; } return 0; }