#include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++) #define rep(i,n) reps(i,0,n) const int INF = 1e9; struct edge { int to, cap, rev;}; const int MAX_V = 1e4; vector G[MAX_V]; bool used[MAX_V]; void add_edge(int from,int to,int cap){ // printf("%d,%d,%d\n",from,to,cap); G[from].push_back({to,cap,(int)G[to].size()}); G[to].push_back({from,0,(int)G[from].size()-1}); } int dfs(int v,int t,int f){ if(v == t) return f; used[v] = true; rep(i,G[v].size()){ edge &e = G[v][i]; if(!used[e.to] && e.cap > 0){ 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; } int max_flow(int s,int t){ int flow = 0; for(;;){ memset(used,0,sizeof(used)); int f = dfs(s,t,INF); if(f==0)return flow; flow += f; } } int n; vector A; int main(){ cin >> n; int s = 2*n+1, t = 2*n + 2; A.resize(n); rep(i,n){ cin >> A[i]; } rep(i,n){ add_edge(s,i,1);//s -> i add_edge(i+n,t,1);//i+n -> t } rep(i,n){ rep(j,n){ if(j != A[i]) add_edge(i,j+n,1); } } int flow=max_flow(s,t); //cout << flow<< endl; if(flow == n){ rep(i,n){ rep(j,G[i].size()){ if(G[i][j].cap == 0 && G[i][j].to < 2*n+1){ cout << G[i][j].to -n << endl; break; } } } }else{ cout << -1 << endl; } return 0; }