#include // #pragma GCC optimize(1,2,3,"Ofast","inline") // #pragma GCC optimize("O3,unroll-loops") // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") using namespace std; #define int i64 #define FF first #define SS second #define SZ(x) ((i32)(x).size()) #define PB push_back #define EB emplace_back #define all(x) (x).begin(), (x).end() using i128 = __int128_t; using ui64 = uint64_t; using i64 = int64_t; using ui32 = uint32_t; using i32 = int32_t; using ld = long double; using P32 = pair; using P64 = pair; const i64 INF = 1e18; const ld eps = 1e-8L; mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); i64 randint(i64 l, i64 r) { uniform_int_distribution<> dis(l, r); return dis(mt); } // double randld(i64 l, i64 r) { uniform_real_distribution<> dis(l, r); return dis(mt); } bool chmin(auto &a, auto b) { return (b < a) and (a = b, true); } bool chmax(auto &a, auto b) { return (a < b) and (a = b, true); } 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"; } const i32 msize = 200000; char buf[msize], *p1 = buf, *p2 = buf; char obuf[msize], *p3 = obuf; #define getc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, msize, stdin), p1 == p2) ? EOF : *p1++) #define putac(x) (p3 - obuf < msize) ? (*p3 ++ = x) :(fwrite(obuf, p3 - obuf, 1, stdout), p3 = obuf, *p3 ++ = x) template inline void read(T &x) { x = 0; i32 f = 1; char ch = getc(); for (; ch < 48 || ch > 57; ch = getc()) if (ch == '-') f = -1; for (; ch >= 48 && ch <= 57; ch = getc()) x = (x << 3) + (x << 1) + (ch ^ 0x30); x = x * f; } template void write(const T &x) { static i32 c[40]; if (!x) { putac('0'); return; } i32 len = 0; T k1 = x; if (k1 < 0) k1 = -k1, putac('-'); while (k1) c[len++] = k1 % 10 ^ 48, k1 /= 10; while (len--) putac(c[len]); } void write(const char *str) { while (*str) putac(*str++); } void write(const string &str) { for (char c : str) putac(c); } void write(const char &c) { putac(c); } template inline void read(T &x, Args&... args) { read(x); // ??????? (read(args), ...); // ????????? } template inline void write(const T &x, const Args&... args) { write(x); write(args...); } // ? // ???? // ???? | _? _l // ? ????` ??X? // ?? ? /??? ?| // ??? /? ??? ? // ? ? ???|?|?| // ???|?? |?|?| // ?| (???_?_)__) // ???? // ? void OUO(); i32 main() { // ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); i32 t = 1; for (i32 tt = 0; tt < t; tt++){ OUO(); } fwrite(obuf, p3 - obuf, 1, stdout); } void OUO() { i32 n; read(n); vector vec(n), aa(n); for (auto &x : vec) read(x); for (i32 i = 0; i < n; i++) aa[i] = i; bool flag = 0; for (i32 i = 0; i < 1000000; i++) { shuffle(aa.begin(), aa.end(), mt); bool iscon = 0; for (i32 i = 0; i < n; i++) if (aa[i] == vec[i]) { iscon = 1; break; } if (iscon) continue; flag = 1; break; } if (flag) for (i32 i = 0; i < n; i++) write(aa[i], ' '); else write(-1, '\n'); } // ?????????????????????????????? // ?????????????????????????????? // ?????????????????????????????? // ?????????????????????????????? // ?????????????????????????????? // ?????????????????????????????? // ?????????????????????????????? // ?????????????????????????????? // ?????????????????????????????? // ?????????????????????????????? // ?????????????????????????????? // ?????????????????????????????? // ??????????????????????????????