#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define ALLOF(c) (c),begin(), (c),end() typedef long long ll; int main() { int n; int a[50]; int hate_count[50]; int dispatched[50]; fill(dispatched,dispatched + 50, -1); fill(hate_count,hate_count+50, 0); cin >> n; rep(i,n) { cin >> a[i]; } rep(i,n) { hate_count[a[i]]++; } rep(i,n) { int need_dispatch = 0; int tmp_c = -1; rep(j,n) { if (tmp_c < hate_count[j]) { if(hate_count[i] == n) { cout << -1 << endl; return 0; } need_dispatch = j; tmp_c = hate_count[j]; } } #ifdef _DEBUG cout << tmp_c << " " << need_dispatch << endl; #endif _DEBUG rep(j,n) { if (dispatched[j] == -1 && a[j] != need_dispatch) { #ifdef _DEBUG cout << "dispatched in" << j << endl; #endif _DEBUG dispatched[j] = need_dispatch; break; } } } rep(i,n) { cout << dispatched[i] << endl; } return 0; }