#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll glb;
vector<ll>inv(100001);
void build_tree(vector<ll>&a, ll int s,ll int e, ll int *tree, ll int index)
{
if(s==e)
{
// deb3(index,s,a[s]);
tree[index] = a[s];
return;
}
ll int mid = (s+e)/2;
build_tree(a,s,mid,tree,2*index);
build_tree(a,mid+1,e,tree,2*index+1);
tree[index] += tree[2*index]+tree[2*index+1];
return;
}
ll query(ll *tree,ll ss,ll se,ll & nm ,ll index)
{
//complete overlap
if(glb!=-1||tree[index]==0)
return INT_MAX;
if(tree[index]<nm)
{
nm -= tree[index];
return INT_MAX;
}
if(ss == se)
{
glb = ss;
return ss;
}
//partial overlap
ll int mid = (ss + se)/2;
ll int left = query(tree,ss,mid,nm,2*index);
ll int right = query(tree,mid+1,se,nm,2*index+1);
return min(left,right);
}
//point update
void point_update(ll *tree, ll ss,ll se, ll i,ll inc,ll index)
{
if(i>se || i<ss)
return;
if(ss == se)
{
tree[index] = inc;
return;
}
ll int mid = (ss + se)/2;
point_update(tree,ss,mid,i,inc,2*index);
point_update(tree,mid+1,se,i,inc,2*index+1);
tree[index] = tree[2*index]+tree[2*index+1];
return;
}
void solve()
{
int n;
cin>>n;
ll tree[4*n+1]={0};
fill(inv.begin(),inv.end(),1);
build_tree(inv,0,n-1,tree,1);
ll a[n];
for(int i=0;i<n;i++)
cin>>a[i];
ll sum = n;
vector<ll> ans;
for(int i=n-1;i>=0;i--)
{
glb=-1;
ll y = a[i];
y = sum-y;
// deb(y);
ll x = query(tree,0,n-1,y,1);
// deb(x);
point_update(tree,0,n-1,x,0,1);
ans.push_back(x);
sum--;
}
reverse(ans.begin(),ans.end());
for(int i=0;i<ans.size();i++)
cout<<ans[i]+1<<" ";
cout<<endl;
return;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll int t=1;
// cin>>t;
while(t--)
{
solve();
}
return 0;
}
CiNpbmNsdWRlIDxiaXRzL3N0ZGMrKy5oPgp1c2luZyBuYW1lc3BhY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