# Code

#include <cstdio>
#include <algorithm>
#define lowbit(x) ((x)&(-x))
#define N 300010
#define ll long long
using namespace std;

struct edge{int to,nex;}e[N*2];
struct que{int x,y,z;}q[N];
const int Inf=1e9;
ll T[N];

int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}

}

ll query(int x){
ll res=0;
for(;x;x-=lowbit(x)) res+=T[x];
return res;
}

for(;x<=m;x+=lowbit(x)) T[x]+=v;
}

void opera(int k,int f){
}

bool mk[N];
inline void solve(int l,int r,int L,int R){
if(l>r) return;
if(L==R){
for(int i=l;i<=r;++i) Ans[id[i]]=L;
return;
}
int mid=(L+R)>>1;
for(;tmp<=mid;) opera(++tmp,1);
for(;tmp>mid;) opera(tmp--,-1);
int cnt=0,u;ll tot;
for(int i=l;i<=r;++i){
tot=0,u=id[i];
int v=e[j].to;
tot+=query(v);
if(tot>=A[u]) break;
}
if(tot>=A[u]) mk[u]=1,cnt++;
else mk[u]=0;
}
int l1=l,l2=l+cnt;
for(int i=l;i<=r;++i)
if(mk[id[i]]) tmp2[l1++]=id[i];
else tmp2[l2++]=id[i];
for(int i=l;i<=r;++i) id[i]=tmp2[i];
solve(l,l1-1,L,mid);
solve(l1,l2-1,mid+1,R);
}

int main(){