N, M = map(int, input().split()) p = 1 for a in map(int, input().split()): if p == 1: p == a elif p > a: p -= 1 print(p)