#include #include #include #include #include using namespace std; #define rep(i,n) for(int i=0;i seat; vector ans; bool solve(vector seat,int index) { rep(i, n) { if (!seat[i] && i!=a[index]) { seat[i] = true; if (index==n-1) { ans[index] = i; return true; } if (solve(seat, index + 1)) { ans[index] = i; return true; } else seat[i] = false; } } return false; } int main() { cin >> n; seat.resize(n); ans.resize(n); rep(i, n) { cin >> a[i]; } if (solve(seat, 0)) { rep(i, n) { cout << ans[i] << endl; } } else cout << -1 << endl; return 0; }