#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++) #define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--) #define iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++) #define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end()) #define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end()) #define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end()) #define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val)) #define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val)) typedef long long ll; class BinaryIndexTree{ public: vector bit; int bit_size; BinaryIndexTree(int size){ bit_size=size+1; bit.resize(size+1); for(int i=0;i0){ res+=bit[i]; i-=i&-i; } return res; } void add(int i, int x){ while(i<=bit_size){ bit[i]+=x; i+=i&-i; } } }; map wcnt; int main(){ BinaryIndexTree inst(1000010); int N,K; cin>>N>>K; REP(i,N){ int w; cin>>w; if(w<0){ if(wcnt.find(abs(w))!=wcnt.end()){ if(wcnt[abs(w)]>0){ wcnt[abs(w)]--; inst.add(abs(w),-1); } } }else{ int sum=inst.sum(1000010)-inst.sum(abs(w)-1); if(sum