#include #include #include #include #include #include #include using namespace std; int main() { int n; cin >> n; vector a(n, 0); set nums; for (int i = 0; i < n; i++) { cin >> a[i]; nums.insert(a[i]); } if (nums.size() == 1) { cout << -1 << endl; return 0; } vector s(n); for (int i = 0; i < n; i++) { s[i] = i; } bool ok; while(1) { ok = true; for (int i = 0; i < n; i++) { if (s[i] == a[i]) { ok = false; break; } } if (ok) { break; } random_shuffle(s.begin(), s.end()); } for (int i = 0; i < n; i++) { cout << s[i] << endl; } return 0; }