#define _GLIBCXX_FILESYSTEM
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 5e5 + 10;
int a[MAXN], ans[MAXN], eq[MAXN], g[MAXN];
int n, q;

void solve() {
    deque <int> pos;
    int buffer = 0, cnt = 0;

    ans[1] = 1;
    buffer = a[1];

    cnt = 2;

    for (int i = 2; i <= n; i++) {
        if (buffer == a[i]) {
            if (n - i + 1 - eq[i] > pos.size()) pos.push_back(cnt++);
            ans[i] = cnt++;

            continue;
        }

        if (pos.size()) {
            ans[i] = pos.front();
            pos.pop_front();

            continue;
        }

        buffer = a[i];
        ans[i] = cnt++;
    }
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n;// >> q;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    for (int i = n; i >= 1; i--) {
        eq[i] = ++g[a[i]];
    }

    bool f = 0;
    solve();

    for (int i = 1; i <= n; i++) {
        cout << ans[i] << ' ';
    }
    
    return 0;

    while (q--) {
        int t, x;
        cin >> t >> x;

        if (t == 1) {
            swap(a[x], a[x + 1]);
            f = 0;
        } else {
            if (!f) {
                f = 1;
                solve();
            }
            
            cout << ans[x] << '\n';
        }
    }

    return 0;

}