#include <bits/stdc++.h>
using namespace std;
typedef long long ll; const int N = 50000; ll elapsed_time[ N + 1 ]; typedef vector< int > vector_t;
struct pending_tasks_t: vector_t
{
int order( int i )
{
return lower_bound( begin(), end(), i ) - begin();
}
void remove_task( int i )
{
erase( lower_bound( begin(), end(), i ) );
}
};
struct pending_tasks_map_t: map< int, vector_t >
{
void round_robin( ll time, pending_tasks_t& pending_tasks )
{
ll p = pending_tasks.size();
for( int key, elapsed_cycles = 2; not empty(); elapsed_cycles = key + 1 )
{
auto it = begin(); time += ( ( key = it->first ) - elapsed_cycles ) * p + 1;
for( auto i: it->second )
elapsed_time[ i ] = time + pending_tasks.order( i );
for( auto i: it->second )
pending_tasks.remove_task( i );
time += p - 1, p -= it->second.size(), erase( it );
}
}
};
int main()
{
ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );
int n; cin >> n; pending_tasks_t pending_tasks; pending_tasks_map_t pending_tasks_map;
for( int i = 1; i <= n; i++ )
{
int t; cin >> t;
if ( t == 1 )
elapsed_time[ i ] = i;
else
pending_tasks_map[ t ].push_back( i ), pending_tasks.push_back( i );
}
pending_tasks_map.round_robin( n, pending_tasks );
for( int i = 1; i <= n; i++ )
cout << elapsed_time[ i ] << '\n';
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdHlwZWRlZiBsb25nIGxvbmcgbGw7IGNvbnN0IGludCBOID0gNTAwMDA7IGxsIGVsYXBzZWRfdGltZVsgTiArIDEgXTsgdHlwZWRlZiB2ZWN0b3I8IGludCA+IHZlY3Rvcl90OwoKc3RydWN0IHBlbmRpbmdfdGFza3NfdDogdmVjdG9yX3QKewogICAgaW50IG9yZGVyKCBpbnQgaSApCiAgICB7CiAgICAgICAgcmV0dXJuIGxvd2VyX2JvdW5kKCBiZWdpbigpLCBlbmQoKSwgaSApIC0gYmVnaW4oKTsKICAgIH0KCiAgICB2b2lkIHJlbW92ZV90YXNrKCBpbnQgaSApCiAgICB7CiAgICAgICAgZXJhc2UoIGxvd2VyX2JvdW5kKCBiZWdpbigpLCBlbmQoKSwgaSApICk7CiAgICB9Cn07CgpzdHJ1Y3QgcGVuZGluZ190YXNrc19tYXBfdDogbWFwPCBpbnQsIHZlY3Rvcl90ID4KewogICAgdm9pZCByb3VuZF9yb2JpbiggbGwgdGltZSwgcGVuZGluZ190YXNrc190JiBwZW5kaW5nX3Rhc2tzICkKICAgIHsKICAgICAgICBsbCBwID0gcGVuZGluZ190YXNrcy5zaXplKCk7CgogICAgICAgIGZvciggaW50IGtleSwgZWxhcHNlZF9jeWNsZXMgPSAyOyBub3QgZW1wdHkoKTsgZWxhcHNlZF9jeWNsZXMgPSBrZXkgKyAxICkKICAgICAgICB7CiAgICAgICAgICAgIGF1dG8gaXQgPSBiZWdpbigpOyB0aW1lICs9ICggKCBrZXkgPSBpdC0+Zmlyc3QgKSAtIGVsYXBzZWRfY3ljbGVzICkgKiBwICsgMTsKCiAgICAgICAgICAgIGZvciggYXV0byBpOiBpdC0+c2Vjb25kICkKICAgICAgICAgICAgICAgIGVsYXBzZWRfdGltZVsgaSBdID0gdGltZSArIHBlbmRpbmdfdGFza3Mub3JkZXIoIGkgKTsKCiAgICAgICAgICAgIGZvciggYXV0byBpOiBpdC0+c2Vjb25kICkKICAgICAgICAgICAgICAgIHBlbmRpbmdfdGFza3MucmVtb3ZlX3Rhc2soIGkgKTsKCiAgICAgICAgICAgIHRpbWUgKz0gcCAtIDEsIHAgLT0gaXQtPnNlY29uZC5zaXplKCksIGVyYXNlKCBpdCApOwogICAgICAgIH0KICAgIH0KfTsKCmludCBtYWluKCkKewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyggZmFsc2UgKSwgY2luLnRpZSggbnVsbHB0ciApLCBjb3V0LnRpZSggbnVsbHB0ciApOwoKICAgIGludCBuOyBjaW4gPj4gbjsgcGVuZGluZ190YXNrc190IHBlbmRpbmdfdGFza3M7IHBlbmRpbmdfdGFza3NfbWFwX3QgcGVuZGluZ190YXNrc19tYXA7CgogICAgZm9yKCBpbnQgaSA9IDE7IGkgPD0gbjsgaSsrICkKICAgIHsKICAgICAgICBpbnQgdDsgY2luID4+IHQ7CgogICAgICAgIGlmICggdCA9PSAxICkKICAgICAgICAgICAgZWxhcHNlZF90aW1lWyBpIF0gPSBpOwogICAgICAgIGVsc2UKICAgICAgICAgICAgcGVuZGluZ190YXNrc19tYXBbIHQgXS5wdXNoX2JhY2soIGkgKSwgcGVuZGluZ190YXNrcy5wdXNoX2JhY2soIGkgKTsKICAgIH0KCiAgICBwZW5kaW5nX3Rhc2tzX21hcC5yb3VuZF9yb2JpbiggbiwgcGVuZGluZ190YXNrcyApOwoKICAgIGZvciggaW50IGkgPSAxOyBpIDw9IG47IGkrKyApCiAgICAgICAgY291dCA8PCBlbGFwc2VkX3RpbWVbIGkgXSA8PCAnXG4nOwp9