n,m=map(int,input().split()) a=list(map(int,input().split())) a.reverse() ans=0 for i in range(m): if ans==0: ans=a[i]-1 elif ans<=a[i]-1: ans-=1 print(ans+1)