N,K=map(int,raw_input().split());M=10**6+1;B=[0]*M;C=[0]*M def A(a,w): while a0:r+=B[a];a-=a&(-a) return r while N: N-=1;w=input() if w>0: if S(M-w)0:A(M+w,-1);C[-w]-=1 print S(M-1)