#include using namespace std; namespace { typedef double real; typedef long long ll; template ostream& operator<<(ostream& os, const vector& vs) { for (auto& v : vs) { os << v << endl; } return os; } template istream& operator>>(istream& is, vector& vs) { for (auto it = vs.begin(); it != vs.end(); it++) is >> *it; return is; } int N; vector A; void input() { cin >> N; A.clear(); A.resize(N); cin >> A; } void solve() { vector ng_exist(N, false); vector> ng_id(N); for (int i = 0; i < N; i++) { ng_id[A[i]].push_back(i); ng_exist[A[i]] = true; } vector wildcard; for (int i = 0; i < N; i++) if (not ng_exist[i]) wildcard.push_back(i); //cout << "ng_id: " << ng_id << endl; //cout << "wildcard: " << wildcard << endl; vector id(N, -1); for (int i = 0; i < N; i++) { if (ng_id[i].empty()) continue; int x = ng_id[i][0]; int next = (i + 1) % N; while (ng_id[next].empty()) next = (next + 1) % N; if (i == next) { cout << -1 << endl; return; } id[x] = next; for (int j = 1; j < ng_id[i].size(); j++) { id[ng_id[i][j]] = wildcard.back(); wildcard.pop_back(); } } cout << id << endl; } } int main() { input(); solve(); return 0; }