#include #include #include using namespace std; void debug() {} template void debug(T var) { cerr << var; } template void debug(T var, P ...t) { cerr << var << ", "; debug(t...); } template void org(T l, T r) { while(l != r) cerr << *l++ << ' '; } #define de(...) { cerr << "[Line: " << __LINE__ << "][" << #__VA_ARGS__ << "] -> [", debug(__VA_ARGS__), cerr << "]\n"; } #define orange(...) { cerr << "[Line: " << __LINE__ << "][" << #__VA_ARGS__ << "] -> [", org(__VA_ARGS__), cerr << "]\n"; } #define All(x) (x).begin(), (x).end() constexpr int RT = 1e7; mt19937 mt(chrono::steady_clock::now().time_since_epoch().count()); int main() { int N; cin >> N; vector A(N); for(auto& i : A) cin >> i; vector ans(N); iota(All(ans), 0); auto check = [&]() -> bool { for(int i = 0; i < N; ++i) { if(ans[i] == A[i]) return false; } return true; }; for(int rt = 0; rt < RT; ++rt) { if(check()) break; shuffle(All(ans), mt); } if(check()) for(auto& i : ans) cout << i << '\n'; else cout << "-1\n"; }