#include #include #include #include #include using namespace std; #define rep(i,n) for(int i=0;i seat,a; int main() { cin >> n; seat.resize(n); a.resize(n); rep(i, n) { cin >> a[i]; seat[i] = i; } bool flag = true, flag2 = true;; while (flag && flag2) { rep(i,n) { if (a[i] == seat[i]) { bool fin = true; rep(j, n) { if (a[j] != seat[i]) { cout << 1 << endl; swap(seat[i], seat[j]); break; } if (j == n - 1) { cout << -1 << endl; flag2 = false; } } flag = false; rep(j, n) { if (a[j] == seat[j]) flag = true; } break; } } } if (flag2) { rep(i, n) { cout << seat[i] << endl; } } return 0; }