N,M = map(int,raw_input().split()) A = map(int,raw_input().split()) h = A[-1] for a in reversed(A[:-1]): if a >= h: h-=1 print h