n,m = map(int,input().split()) *a, = map(int,input().split()) v = 0 for ai in a[::-1]: if v==0: v = ai-1 elif v <= ai-1: v -= 1 print(v+1)