n,d=map(int,input().split()) l=list(map(int,input().split()))+[0] p=[0] for i in range(n-1): if l[i]